I have an script that receives an string as a parameter, for example:
@C:/myScript.sql "AXEL DAVID";
my scripts basically constructs a Parameterized query an execute it. That's all. It works most of the time, except when the parameter contains apostrophes
DEFINE myparameter = &&1
myquery := "Select * from myTable where x = :p1";
EXECUTE IMMEDIATE myquery into results USING myparameter;
When trying the following;
I get the following error:
Bind Variable "p1" is NOT DECLARED
Of course if I change the parameter as "o''neal" It will work, but I will end up with other issues later on, so I would like to know how can I deal with apostrophe on dynamic queries.
I also tried to use the following:
myquery := "Select .... where x = " || Q'#:p1#';
but not working.
any hint will be appreciated =)
Edited by: user13679988 on Nov 22, 2012 3:12 PM
Edited by: user13679988 on Nov 22, 2012 3:38 PM
Edited by: user13679988 on Nov 22, 2012 3:45 PM
DUPLICATE THREAD! and WRONG FORUM!
This forum is for SQL Developer questions only and your question has nothing to do with sql developer. Please mark this question ANSWERED.
You have already posted this question in the SQL and PL/SQL forum and should continue to use that thread. How to replace 2 single quotes to single quote