Pass values from file to WHERE clause in query

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
pratyusha
Participant
Posts: 50
Joined: Wed Nov 22, 2006 4:58 am

Pass values from file to WHERE clause in query

Post by pratyusha »

I have a flat file which has some 20 values in it. I have to run a query for these 20 values. So these values need to come into a WHERE clause. I have searched the forums to check for an answer but I am not able to find one. Is this approach possible? Can any one please suggest some ideas?

These values would be updated everyday. So I run a job to load the values into the flat file and then run another job with these new values.

Thanks
Prathyusha
sachin1
Participant
Posts: 325
Joined: Wed May 30, 2007 7:42 am
Location: india

Re: Pass values from file to WHERE clause in query

Post by sachin1 »

your operating system is unix as you mentioned so it will be great that you create one more file which will have just one single record from your file which is having 20 values and use this file having single record for your lookup condition.

you can create a single record from file havig 20 records in your before job subroutine.
pratyusha
Participant
Posts: 50
Joined: Wed Nov 22, 2006 4:58 am

Post by pratyusha »

Can I pass these values as a parameter to the job?

Thanks
Prathyusha
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

Yes. Give it a shot.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
pratyusha
Participant
Posts: 50
Joined: Wed Nov 22, 2006 4:58 am

Post by pratyusha »

Thanks for your patience but how to pass it as parameter to DS job..
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

You can.

Do an executeCommand to cat the file into a variable and pass it as a parameter.

If it is characters, it will be tricky to add quotes around.

Alternatively do a before job work to include your SQL and cat the 'where' to form a new SQL file and use it in the query.
pratyusha
Participant
Posts: 50
Joined: Wed Nov 22, 2006 4:58 am

Post by pratyusha »

Thanks for your prompt reply. It is not characters and just numbers so that is fine.
But will DSSetParam work from Before/After subroutines
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

NO. That's too late as the job has already started. You need a Sequence job to gather the values and then pass them in to the Job Activity stage to run the job.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply