SQL task output in another sql task - VisualCron - Forum

Community forum

karthik0108
2020-02-11T15:36:04Z
Hi,
I have a job with multiple sql tasks (15), now all these tasks needs a temporary table with some value and a match needs to be made against it.

My question is, is it possible to use result set of one task and use it in another sql task?

I hope there is an easier way then to create the same temp table in all 15 task.
Support
2020-02-12T10:55:44Z
Originally Posted by: karthik0108 

Hi,
I have a job with multiple sql tasks (15), now all these tasks needs a temporary table with some value and a match needs to be made against it.

My question is, is it possible to use result set of one task and use it in another sql task?

I hope there is an easier way then to create the same temp table in all 15 task.



Hi Karthik,

Are you a customer today? I need to place you in your company portal to keep things organized if you are (or what is your company email? we prefer users using company emails rather than yahoo/gmail)

As for your question, first, what version are you using?
Michael
Support
http://www.visualcron.com 

Please like  VisualCron on facebook!
jrtwynam
2020-04-23T18:15:02Z
It is possible, but it's tedious. It really depends on how you want the result set to be used. For example, if you have a query that returns a value that you want to use in a subsequent query, you could pass it into the subsequent query something like this:


select *
from table_a
where criteria_1 = '{TASK(Query1TaskID|StdOut)}'


But that method would only work if the first query returns only a single value. If your first query returns multiple fields,


select *
from table_a
where criteria_1 = '{STRING(GetColumn|1|1|,|{TASK(Query1TaskID|StdOut)})}'
and criteria_2 = '{STRING(GetColumn|1|2|,|{TASK(Query1TaskID|StdOut)})}'


If your first query returns 1 field but multiple records, you could have your first query set up to return something in CSV format, something like this:


select '"' || field_1 || '","
from table_a


That would return results something like this:


"result 1",
"result 2",
"result 3"


And then you could set up your subsequent query like this:


select *
from table_a
where criteria_1 in ({TASK(Query1TaskID|StdOut)})
Scroll to Top