Multiple value in job parameter

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
ankita
Participant
Posts: 57
Joined: Sun Nov 13, 2005 11:17 pm

Multiple value in job parameter

Post by ankita »

Hi All,
I want to pass one or multiple values through a job parameter which will be used in IN clause of a SQL.
E.g. Job parameter : Destination
SELECT * FROM DEST WHERE DESTINATION IN (#Destination#);

Destination will have varchar values as ABCD, XYZ etc. If I am taking the job parameter as string then it's not accepting single quote, but finally the SQL should be like DESTINATION IN ('ABCD','XYZ').
Please suggest how to implement it using one parameter.

Thanks in advance !
Ankita
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Escape the quotes by putting a back-slash (\) before each one.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ankita
Participant
Posts: 57
Joined: Sun Nov 13, 2005 11:17 pm

Post by ankita »

Hi Craig,
I have tried passing \'XYZ\',\'ABCD\' and \'XYZ\'\,\'ABCD\', but none of these is working. Is there any other way to implement it ?

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

Post by ray.wurlod »

What precisely do you mean by "not accepting"?
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 »

"Not working" means what here, what ends up in the job? And what stage / database are we discussing here?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ankita
Participant
Posts: 57
Joined: Sun Nov 13, 2005 11:17 pm

Post by ankita »

The SQL has below where clause,

FINAL_DEST_UN_COD IN (#AB_Parm.PORT_OF_DESTINATION#)

I have passed value as \'USCMH\',\'HKHKG\'

Job is aborting with below error :
main_program: [DataDirect][ODBC DB2 Wire Protocol driver][UDB DB2 for OS/390 and z/OS]ILLEGAL SYMBOL \; VALID SYMBOLS ARE ( + - ? : CASE CAST USER SELECT <FLOAT> CURRENT NEXTVAL PREVVAL.

The parameter is defined as String and it's DB2 table. Please help !

Thanks,
Ankita
ankita
Participant
Posts: 57
Joined: Sun Nov 13, 2005 11:17 pm

Post by ankita »

It's a ODBC Enterprise stage used to fetch data from DB2 table.
Ankita
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Do the logs show you what the actual sql ends up being for the query?
-craig

"You can never have too many knives" -- Logan Nine Fingers
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Where does the problem occur? Running from Director or running from unix command line dsjob and passing in this list as a parameter value? You're going to have to consider that any parameter values must also work from the command line if you're using any scheduling tools.

What you are trying to do seems easy but it has been tried for YEARS and never works in the end. Your best solution is to generate the complete SQL statement and write to a file and then use the "run SQL from file" feature. Even better, create a work table to hold the values and change your IN to an IN (select values from worktable) query.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ankita
Participant
Posts: 57
Joined: Sun Nov 13, 2005 11:17 pm

Post by ankita »

I tried from Data Stage , as well as from Unix. In either case it's not fetching values.
Kept the SQL as, WHERE DEST in ('#DESTINATIONS#') and passed value as ABC','XYZ. It's running but not fetching any record. But view data is working.

Then changed the SQL as, WHERE DEST in (#DESTINATIONS#) and passed value as 'ABC','XYZ'. Then it's aborting.

Also tried with back slash (from director) before every single quote as stated earlier, that's also aborting.

I want to know the Data Stage solution i.e. how to pass value when run from Director. Then I can change the shell script accordinly.

Director log (OSH script) doesn't show the final SQL, it shows the SQL with parameter. Is ther any other way to check the final SQL ?

Thanks for your replies,
Ankita
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

ankita wrote:Director log (OSH script) doesn't show the final SQL, it shows the SQL with parameter.
:?: If we were discussing a Server job here, that - the 'non translation' of a job parameter in the logs - would imply the parameter name didn't exist in the job. Is the same not true here? How, in a PX job, does one find out the final fully parameter substituted SQL a stage is attempting to run?

General question for the home audience.
-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 »

Anyone looked at the score, rather than the generated OSH?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply