Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem in escaping single quote

502844Mar 11 2007 — edited Mar 11 2007
Hello,
I am sorry for the appearance of the message,but couldnt help it. I tried to put spaces but there is some problem.


A very basic level query,I am trying to execute this query,




SELECT TO_CHAR (TO_DATE ('Friday, July 28, 2006', 'Day, Month DD, YYYY'),'YYYY-MM-DD') d FROM DUAL;

It works fine.

I am trying to use it in my PL/SQL code, which has the following query

execute immediate 'SELECT'|| TO_CHAR (TO_DATE (||''temp.eventdate''||', ''Day, Month DD, YYYY''),''YYYY-MM-DD'')'||'d FROM DUAL into dateformat';


But it gives me error,




LINE/COL ERROR
-------- -----------------------------------------------------------------
62/48 PLS-00103: Encountered the symbol "|" when expecting one of the
following:
( ) - + case mod new not null others select <an identifier>
<a double-quoted delimited-identifier> <a bind variable>
table avg count current exists max min prior sql stddev sum
variance execute multiset the both leading trailing forall
merge year month DAY_ hour minute second timezone_hour
timezone_minute timezone_region timezone_abbr time timestamp
interval date
<a string literal with character set specific

temp.eventdate is a variable storing date,its of type varchar.


What I understand is to escape single quote ,we need to type double quote



Can some one please explain me whats wrong in the query which I am trying to write????and how to write it correctly.

I will high appreciate it.

Thanks

Regards

Prateek
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 8 2007
Added on Mar 11 2007
7 comments
1,037 views