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

Home -> Community -> Usenet -> c.d.o.server -> Re: PL/SQL - Dynamic SQL

Re: PL/SQL - Dynamic SQL

From: Matthias Gresz <GreMa_at_t-online.de>
Date: Wed, 03 Feb 1999 14:19:11 +0100
Message-ID: <36B84CCF.6005278E@Privat.Post.DE>

Philippe schrieb:
>
> Try this :
>
> sql_str = 'select col1, col2 from ' || table_name || ' where col3 = ''' ||
> char_var || ''''
>
> HTH
>
> Philippe
>
> Detlev Goebel wrote in message <36B8198B.F637A4BC_at_www.gzs.de>...
> >Hello all
> >
> >I'm in need to create a stored procedure with dynamic sql.
> >
> >The query looks like that :
> >
> >sql_str = 'select col1, col2 from ' || table_name || ' where col3 = ' ||
> >char_var
> >
> >The Problem: There are no single quotes at var_char and dbms_sql.parse
> >pops up an error message
> >saying invalid column name. Now I'm trying to get the single quotes in
> >that string but that doesn't work so far.
> >
> >Is there somone on the list who could help me ???
> >

Not beeing in need to count the number of single quotes, you may use (depending on platform):

sql_str = 'select col1, col2 from ' || table_name || ' where col3 = ' || chr(39) ||
char_var || chr(39)

HTH
Matthias
--
Matthias.Gresz_at_Privat.Post.DE

Always log on the bright side of life.
http://www.stone-dead.asn.au/movies/life-of-brian/brian-31.htm Received on Wed Feb 03 1999 - 07:19:11 CST

Original text of this message

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