How do you get data from SQL Query Results?

  • 10 April 2015
  • 6 replies
  • 5 views

Badge +6

Hi Guys,

 

I need your help. When you have a query that runs against a SQL Table and returns data into 3 columns, how do you put these results a collection that you can use. Is there a way to do this?

For Example: My sql table returns the following results

Trading IDPortfolio
8868BMBTH
9898CBGFk
9899GTGFU

 

I think my effort has been able to get the first column value but not the 2nd or 3rd column.

What am I missing?

 

Regards

 

Bhuti


6 replies

Userlevel 5
Badge +12

In the Execute SQL action, right under the Query section, you'll see a "Column to retrieve" box.  There you just specify the name of the column you want to retrieve and click "Add" button.  This now appears with a drop down next to it beneath the add area, and you can select a collection to which you want to store the values.

Hope this helps,

Mike

Badge +6

Hi Mike,


Yes I see that option but how do I get all the results in the query? When I tried that I got the first results but how do I get 2nd record and 3rd etc?


I guess my confusion is if my SQL is returning many records how do I get the values from that 1 SQL Execution.


Currently I have done many of these where I run the first query to get the value that will give me unique record and I loop through the first query and passing the unique value to get the rest of the fields. In the current situation I don't have a unique field. I hope my explanation is clear.


Regards


Bhuti

Userlevel 5
Badge +12

I reread the original post and following what I said previously: You will be using the "Get" operation within a Collection Operation action - you will have one of these actions for every column of data.   You will use the same "index" which is a number type variable within your loop to get the data from each collection to form a row of data.

Userlevel 5
Badge +12

Did this answer your question? happy.png

Badge +6
Hi Mike,

Haven't tried it yet, Sunday familt time. Will let you know once I have.

Regards 

Bhuti
Badge +9

Bhuti Mbele, Did you get this working? I also get 1 result only after using separate collection operation. What else is needed?

WF

Reply