Page 1 of 1

Parameterizing SQL in oracle Enterprise Stage

Posted: Mon Apr 13, 2009 12:14 pm
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.

Re: Parameterizing SQL in oracle Enterprise Stage

Posted: Mon Apr 13, 2009 1:18 pm
by somu_june
My problem was solved by placing \' and \'

before \'EMPNO~Seq \'




Thanks,
Somaraju.

Posted: Mon Apr 13, 2009 2:37 pm
by chulett
Yup, they need to be "escaped" to be preserved.

Posted: Thu Apr 16, 2009 4:22 pm
by dsuser_cai
Thats right, also make sure that when you have single quote (') you use forward slashes (/).

Posted: Thu Apr 16, 2009 4:56 pm
by ray.wurlod
Forward slashes? I don't think so.

Posted: Wed May 27, 2009 5:06 pm
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.

Posted: Wed May 27, 2009 7:11 pm
by chulett
Suggest you start your own thread.