Populate a variable

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
MrBlack
Participant
Posts: 125
Joined: Wed Aug 08, 2012 8:57 am

Populate a variable

Post by MrBlack »

Can anyone show me how I can use an ODBC connection to select a 1x1 value into a variable/parameter so I can then use that in a WHERE statement on a different ODBC connection in the same job?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I'd be surprised if that could be done. The problem is that all the stages pretty much get started at the same time (assuming a parallel job) so even if your small ODBC stage were to get the variable and write it to a file which is used as the SQL command for the other stage you get concurrency issues.
Although, now that I've written it down, it might be possible to declare that file as a named pipe (are you on UNIX?) which could mean that the two stages communicate with each other via the pipe.
... I checked and the read-from-file option is only for the before/after statements, not for the query.
If both ODBC queries are in the same database then you could do it directly in the write stage.

Perhaps a job sequence, calling up a job to read the "where" clause and setting a user status, which is read by the job sequence and passed as a parameter to your 2nd job, which then processes that parameter as part of the "where" clause.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

ArndW wrote:I'd be surprised if that could be done.
It can't. As Arnd noted, you'll need to re-architect your approach.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You could use the job's user status area as that variable. But you would then need to retrieve it using a routine that invokes DSGetJobInfo() function. Messy, but doable in a server job.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
MrBlack
Participant
Posts: 125
Joined: Wed Aug 08, 2012 8:57 am

Post by MrBlack »

I found a solution, adapting from mhester's post at viewtopic.php?t=91564 to write a routine that would return a 1x1 value. I can run my routine from just about anywhere; passing as a job parameter, user variable stage, etc...

Where there's a will, there's a way!
Post Reply