Passing a string parameter with ' characters

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
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

It should work. What is the error / warning you getting?
Try to excape all the ' charachter with /.
Shouldn't you be having ' before the sting as well??
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
OddJob
Participant
Posts: 163
Joined: Tue Feb 28, 2006 5:00 am
Location: Sheffield, UK

Post by OddJob »

I had exactly the same issue. It seems the DB2 stage likes to strip the quote character - naughty, naughty. I resolved it as follows:

Parameter value did not include the single quotes e.g.
Param=One,Two,Three

My job was being called from a sequence. In the parameter value expression I used the following:
"\'":Ereplace (Param, ",", "\',\'"):"\'"

It looks a bit confusing because of the mixture of double and single quotes, but essentially it is replacing each ,<comma> with ','<single quote><comma><single quote> and prefixing/suffixing with '<single quote>

If you only have a single job you may have to wrap it with a sequence to allow this kind of parameter pre-processing.

Hope this helps.
rony_daniel
Participant
Posts: 36
Joined: Thu Sep 01, 2005 5:44 am
Location: Canada

Post by rony_daniel »

Thank you very much OddJob. Your solution worked for me.

But later I found that I got messed up because the $PROJDEF variable assigning the default value which was wrong.

In my case the starting and ending single quotes are given in the query itself as you can see

select name, id from emp where name in ( ' #name_param# ' )
so only the rest of the single quotes needs to be taken care. Now I find that my original job itself works without wrapping it in a sequencer.

Thanks once again.
Thanks & Regards,
Rony
Post Reply