1 Reply Latest reply: Aug 11, 2017 11:06 AM by Sunny Talwar RSS

    Appending values by WHERE condition in loop

    Андрей Шепель

      Colleagues, good day!
      I have one example to test loading table using WHERE condition, which values are stored in Table field.

       

      My source table:

       

        

      IDField1Field2Condition
      1ABField1='A'
      2CDField1='C'
      3ABField1='C' or Field2='B'
      4ACField2='K'
      5AKField2='D'

       

      My task is to load new table using for loop statement and each iteration (quantity of iterations is equal to unique numbers of Conditions) of this loop must append new values using WHERE condition corresponds to field Condition.

       

      For example.

      1. First iteration: We read the table and create only those values, which corresponds to Condition #1: Field1='A'

        

      IDField1Field2Condition
      1ABField1='A'
      3ABField1='C' or Field2='B'
      4ACField2='K'
      5AKField2='D'

       

      2. Second iteration: We read the table and append only those values to result of the first iteration, which corresponds to Condition #2: Field1='C'

        

      IDField1Field2Condition
      2CDField1='C'

      After two first iterations, we must fetch the following table:

        

      IDField1Field2Condition
      1ABField1='A'
      3ABField1='C' or Field2='B'
      4ACField2='K'
      5AKField2='D'
      2CDField1='C'

      There're test model and source file in attachment.

      Thanks for the advice.