Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
New Member

DB get step: managing multiple row returned from a table

Hi,

please can someone tell me if it is possible to manage multiple row when returned in a db get step?

For example, I execute a SELECT in db read step to read an SQL table which returns two rows. From each row I get two string variables, let's say: "Var1", "Var2".

Assigning them to local variables, I am able to assign just the 2 variables of the first row, not the variables of the second row.

I tried to use array as local variables with not success, how can I do?

Thanks

3 REPLIES

Re: DB get step: managing multiple row returned from a table

mmaddalena,

You have two options, you can pre populate, or work row by row.

Prepopulate:

     String[] Var1

     int row

     DBGet Loop:

          DBGet

               Successful:

                    save to Var1[row]

                    increment row

                    Goto DBGet Loop

               No data:

                    /* this is the last row */

                    Goto After DB Get Loop

    After DB Get Loop:

          /* do whatever with the data */

Conversely:

Row by row:

     String  Var 1

     int row

     DBGet Loop:

          DBGet

               Successful:

                    /* do whatever with the data */

                    Increment row

                    Goto DBGet Loop

               No data:

                    /* no more data (last row) */

                    Goto After DB Get Loop

     After DB Get Loop:

          /* do whatever after your done with the data */

Tanner Ezell www.ctilogic.com
New Member

Re: DB get step: managing multiple row returned from a table

Hi,

thanks a lot for your answer.

I'm going to execute some test and let you knbow.

Regards,

Michele

New Member

Re: DB get step: managing multiple row returned from a table

Hi tanner,

I try to clarify better our issue.

As example let's say to have the followiing table:

CustomerIDTel1Tel2Tel3
154321675null
0567834563214
1null1456null
5789045673245

Our query in DB GET is the following:

SELECT Tel1,Tel2,Tel3 from table where CustomerID=1

In this case we obtain 2 rows.

Suppose that our local variables (array) are Var1[] and Var2[].

Var1 should be filled with the values of the first row, Var2 with the values of the second row...ecc...

Our first problem is to get the number of rows and use it in a integer variable (I guess the one you called row) in order to perform the loop.

The second problem is how can I assign the variable Tel2 to Var1[2], where 2 is not the second row but the second value of the first columns

Thanks

Regards

276
Views
0
Helpful
3
Replies
CreatePlease to create content