How to pass Query from file to ODBC stage

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
BMSK
Participant
Posts: 41
Joined: Wed Feb 06, 2008 7:00 am
Location: Bangalore

How to pass Query from file to ODBC stage

Post by BMSK »

Hi all,

I want to pass the query to odbc stage in paralell job, that quey is generated in datastage job its in stored in file from that file i want to pass the genrated query in OODBC stage.

thanks
BMSK.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Not possible.

Why do you think you want to do it that way?

There is a way, but you have to generate the query externally to the job (perhaps in a prior job) then pass the query into this job as a parameter value.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Clarify for us if this 'generated query in a file' is generated in the same job as the ODBC stage that will use it or in a previous job? Former bad, latter good. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
BMSK
Participant
Posts: 41
Joined: Wed Feb 06, 2008 7:00 am
Location: Bangalore

Post by BMSK »

In my first job i will be generated query and store in file. In the second job and in ODBC stage i want to read the query from that file and th pull the data.


flow
first job seq->transform->seq

this is the query i generated
SELECT A.CONT_ID, B.CONT_ID AS SUSPECT_CONT_ID FROM DB2ADMIN.MDX_DATA_SRC A,DB2ADMIN.MDX_DATA_SRC B WHERE (A.DEPT= B.DEPT AND A.sat= B.sat ) AND A.CONT_ID<>B.CONT_ID

second job odbcstage-> seq

In ODBC stage how this query will be call it.

thanks
bmsk.
datisaq
Participant
Posts: 154
Joined: Wed May 14, 2008 4:34 am

Post by datisaq »

This you can do at a job sequence level.

Main sequence:-

Job1----->ExecCommand---->job2

In ExecCommand Stage read that file and assign it to a Job parameter say "pQuery".

Then use that parameter "pQuery" in ODBC stage of your job2
IBM Certified - Information Server 8.1
franco
Participant
Posts: 5
Joined: Tue Oct 13, 2009 11:01 pm

Post by franco »

This can't be done from the same sequence. Because the value of the parameter will be initialized when the sequence start .If it is changed in the sequence, it will not reflect.Gurus, correct me if i am wrong
datisaq wrote:This you can do at a job sequence level.

Main sequence:-

Job1----->ExecCommand---->job2

In ExecCommand Stage read that file and assign it to a Job parameter say "pQuery".

Then use that parameter "pQuery" in ODBC stage of your job2
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard.

You're wrong. It can be done in the one sequence, precisely as datisaq outlined.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
franco
Participant
Posts: 5
Joined: Tue Oct 13, 2009 11:01 pm

Post by franco »

ray.wurlod wrote:Welcome aboard.

You're wrong. It can be done in the one sequence, precisely as datisaq outlined. ...
because in one of our job , we have the following sequence

shell script to update the <param1> --> job that use <param1>

but the job was using the old value (i.e. the value before the sequence has started)
BMSK
Participant
Posts: 41
Joined: Wed Feb 06, 2008 7:00 am
Location: Bangalore

Post by BMSK »

Hi

i did the job in the flow J1--> Execute command activity --->J2

I facing the error

Call_sequence..JobControl (@EXE_CAT_SQL): Executed: head C:\Satish\sf_query.txt
Reply=0
Output from command ====>
SELECT A.CONT_ID, B.CONT_ID AS SUSPECT_CONT_ID FROM DB2ADMIN.MDX_DATA_SRC as A,DB2ADMIN.MDX_DATA_SRC as B WHERE (A.'LAST_NAME' is not recognized as an internal or external command,operable program or batch file.= B.'LAST_NAME' is not recognized as an inte

regards
bmsk
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So, it tried to execute your output as DOS commands and got confused. Type using 'type' or 'cat' instead of 'head' and see if that helps.
-craig

"You can never have too many knives" -- Logan Nine Fingers
BMSK
Participant
Posts: 41
Joined: Wed Feb 06, 2008 7:00 am
Location: Bangalore

Post by BMSK »

Hi chulett,

I tried with type, cat as well..but they are also giving the same error..

regards
bmsk
BMSK
Participant
Posts: 41
Joined: Wed Feb 06, 2008 7:00 am
Location: Bangalore

Post by BMSK »

Hi all,

I decleare the environment variable $envtest, when passing the value of $envtest=lastname its working fine.

the same environment varaible when I pass the parameter $envtest= lastname|firstname (with Pipe as delimiter) its not working and throwing error.

regards
bmsk
Post Reply