Parameterizing SQL in oracle Enterprise 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
somu_june
Premium Member
Premium Member
Posts: 439
Joined: Wed Sep 14, 2005 9:28 am
Location: 36p,reading road

Parameterizing SQL in oracle Enterprise Stage

Post by somu_june »

Hi,

Iam passing user defined SQL through a job parameter and statement looks like this psql (Parameter) string and its default value = SELECT * from EMP where EMP_NO = 'EMPNO~Seq'

and in oracle stage Read Method = user-defined and in SQL Query = #psql#.

When this job runs it is failing by throwing the following error

ORAR_EMP_TABLE: GenericQuery:esqlErrorHandler
Prepare failed for: GenericStmt_1

SELECT * from EMP where EMP_NO = EMPNO~Seq
sqlcode is: -911

esql complaint: ORA-00911: invalid character


When I checked above statement from log . Oracle stage is skipping single quotes around EMPNO~Seq. When I re checked the parameter value it has single quotes but when it is passed to the stage single quotes were discarded. Can some one tell me how to solve this problem.

Thanks,
Somaraju.
somaraju
somu_june
Premium Member
Premium Member
Posts: 439
Joined: Wed Sep 14, 2005 9:28 am
Location: 36p,reading road

Re: Parameterizing SQL in oracle Enterprise Stage

Post by somu_june »

My problem was solved by placing \' and \'

before \'EMPNO~Seq \'




Thanks,
Somaraju.
somaraju
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Yup, they need to be "escaped" to be preserved.
-craig

"You can never have too many knives" -- Logan Nine Fingers
dsuser_cai
Premium Member
Premium Member
Posts: 151
Joined: Fri Feb 13, 2009 4:19 pm

Post by dsuser_cai »

Thats right, also make sure that when you have single quote (') you use forward slashes (/).
Thanks
Karthick
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Forward slashes? I don't think so.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
jaganmo
Participant
Posts: 7
Joined: Wed Jan 28, 2009 4:40 pm

Post by jaganmo »

I encountered a similar problem but the \' '\ didn't work for me.

This is my query

select coln from table where coln = \'xyz\'

my where clause changes dynamically in the above query containing one or more expression check depending on run time conditions.

Please suggest any work around.
Regards,
Jaganmohan.R
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Suggest you start your own thread.
-craig

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