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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Q: quotes within quotes

Re: Q: quotes within quotes

From: Remi Delon <rdelon_at_my-dejanews.com>
Date: Tue, 27 Apr 1999 16:33:18 GMT
Message-ID: <7g4ose$12h$1@nnrp1.dejanews.com>


In article <37250AFF.ABD14F1E_at_trw.com>,   Leona Vo <leona.vo_at_trw.com> wrote:
> Hello,
> I'm trying to create a lexical variable with the following query:
> select * from table_name
> &where_var;

You cannot directly do something like that. That would be dynamic SQL. However, you could use :
  declare
    where_name varchar2(20);
  begin
    where_name:='WHOMEVER';
    select * from table_name where name=where_name;

But the name of the column has to be hardcoded. If you want to execute dynamic SQL, take a look at the DBMS_SQL package.

> In my program I have
> :where_var := 'where name = "WHOMEVER"';
>
> Upon running the report I got this error:
> ORA - 00904: Invalid column name select * from table_name where name
> = "WHOMEVER"
>
> I tried single quotes but the compiler would not let me compile.
> However, if I use double quotes as above I get that error because SQL
> doesn't take "" in the where clause. Any ideas? Or am I assigning
> lexical variable incorrectly? How else would I assign a lexical
> variable?
>
> Thank you.
>
>

If you want to use single quotes inside single quotes, you have to put two single quotes in a row. For example, the string that consists of just one single quote is identified by : ''''

Remi

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Tue Apr 27 1999 - 11:33:18 CDT

Original text of this message

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