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

Home -> Community -> Usenet -> c.d.o.tools -> Re: dbms_sql advice

Re: dbms_sql advice

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: 2000/07/24
Message-ID: <964459174.10183.0.pluto.d4ee154e@news.demon.nl>#1/1

The correct approach is
stmt_str := 'select '||field||' from emp where job = :jobname' where of course you'll need to use dbms_sql.bind_value to bind a variable to :jobname.

Hth,

Sybrand Bakker, Oracle DBA

"A Kydd" <akydd_at_gpu.srv.ualberta.ca> wrote in message news:8lhnch$ato$1_at_pulp.srv.ualberta.ca...
> I understand that dbms_sql will allow me to use dynamic queries with a
> select statement such as
> stmt_str := 'SELECT ename, sal
> FROM emp
> WHERE job = :jobname';
>
> I've been trying to do a similar query, but with variables in the SELECT
> clause, as well as in the FROM clause. My query string looks like this:
> stmt_str:= 'SELECT :field
> FROM :myTable
> blah blah blah...';
>
> where field and myTable are later bound to a column and table name.
> However, dbms_sql.parse gives me an error: ORA-00923: FROM keyword not
> found where expected. I've checked and rechecked the string, but have
> found no obvious errors. Is there another way to approach what I'm trying
> to do?
>
>
> --
> ...Alan...
>
> "Have you seen a rubix cube around lately?? Slinky?
> What's happening to our world?" --Tey Steenbergen
Received on Mon Jul 24 2000 - 00:00:00 CDT

Original text of this message

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