Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: How does one escape special characters

Re: How does one escape special characters

From: Mladen Gogala <mgogala_at_allegientsystems.com>
Date: Tue, 25 Jan 2005 13:50:41 -0500
Message-ID: <41F69501.4080900@allegientsystems.com>


Roger Xu wrote:

>Thanks.
>
>Could you tell me what is wrong with the following statements?
>
>

I can, but a little debugging excercise will be beneficial for your muscles and joints.

>SQL> l
> 1 declare
> 2 cmd varchar2(128);
> 3 begin
> 4 cmd:='SELECT id FROM emp WHERE name = ''ROGER XU'';';
> 5 dbms_output.put_line(cmd);
> 6 execute immediate cmd;
> 7* end;
>SQL> /
>SELECT id FROM emp WHERE name = 'ROGER XU';
>declare
>*
>ERROR at line 1:
>ORA-00911: invalid character
>ORA-06512: at line 6
>
>
>

And the script below works! Fancy that! All you need to do is to find out what is the difference.

SQL> ed
Wrote file /tmp/buffer.sql

  1 declare
  2 cmd varchar2(128);
  3 begin
  4 cmd:='SELECT empno FROM emp WHERE ename = ''ROGER XU''';   5 dbms_output.put_line(cmd);
  6 execute immediate cmd;
  7* end;
SQL> /
SELECT empno FROM emp WHERE ename = 'ROGER XU'

PL/SQL procedure successfully completed.

SQL

-- 
Mladen Gogala
Oracle DBA

--
http://www.freelists.org/webpage/oracle-l
Received on Tue Jan 25 2005 - 13:53:14 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US