RE: "Problems with escape sequence in EXECUTE IMMEDIATE",
Greg Gould, July 19, 2004 - 1:37 pm UTC
Thank you!
That worked perfectly.
I agree this is ugly and probably not the best way to do this, but for now it gets the job done, and no this really doesn't have to scale at all.
Thanks again.
And new in 10g....
Gary, July 19, 2004 - 7:33 pm UTC
They've got a new ability in PL/SQL in 10g to use an alternative to 'old' quoting.
From the PL/SQL User's Guide and Reference (Chapter 2 Fundamentals...) :
"
You can also use the following notation to define your own delimiter characters for the literal. You choose a character that is not present in the string, and then do not need to escape other single quotation marks inside the literal:
-- q'!...!' notation to use single quotes inside the literal
string_var := q'!I'm a string, you're a string.!';
"
Escape Characters
syed, September 08, 2004 - 5:31 pm UTC
Thanks Sir, this is excellent
Escape sequences
Syed, September 09, 2004 - 1:09 pm UTC
Tom,
Sorry to bother, but yesterday I was thinking I am successful, but still getting the error;
Can you please help what is the problem, the code is very dynamic.
Just want to update the information at the governing table, but don't know what exactly it is, problem are the 'quotes'.
Your help will be highly appreciated, thanks in advance.
Syed
EXACT CODE:
-- Updating information in the PM_TABLE_DROP_PART table, the governing table --
v_cmd := 'update PM_TABLE_DROP_PART set EXPORT_FILE_NAME = ['||v_stage||'.dmp'||'], EXPORT_DT = ['||SYSDATE||'] where table_name = ['||''||pm_rec.table_name||'] and partition_name = ['||pm_rec.partition_name||']';
dbms_output.put_line(v_cmd);
EXECUTE IMMEDIATE translate('v_cmd','[]','''''''');
Thanks
September 09, 2004 - 1:43 pm UTC
why the heck are you using dynamic sql?
there are so many things wrong there -- first and foremost is the unnecessary attempted use of dynamic sql.
second -- but equally as bad -- is the LACK OF BIND VARIABLES!!!!!!!!!!!! man oh man.
so, i won't even comment on the code (translate of the character string constant 'v_cmd' -- probably meant the variable v_cmd, not the string 'v_cmd'... putting sysdate in there as a string! ack, what happens to the time component -- or what if innocently "alter session set nls_date_format=....." something that does/does not including the time/day, whatever component). Ok, I guess I did comment on the code.
there is no way that should be anything else other than:
....
update pm_table_drop_part
set export_file_name = v_stage || '.dmp',
export_dt = sysdate
where table_name= pm_rec.table_name
and partition_name = pm_rec.partition_name;
.......
anything else is *wrong*
Escape Characters
Syed, September 09, 2004 - 4:12 pm UTC
Sorry Sir,
I was doing so many dynamic sqls, that I just forget this simple thing and was again unnecessarily using execute immediate, where as not required.
Accept my apology for disturbing you and thanks a lot for your help.....
YOU ARE REALLY REMARKABLE