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 -> dynamic-sql question

dynamic-sql question

From: Marc Eilens <eilensm_at_fh-trier.de>
Date: Wed, 04 Nov 1998 10:39:45 +0100
Message-ID: <364020E0.828C9408@fh-trier.de>


Hi,

can anybody tell me when to use the bind_variable-procedure and when to use the concatenation-operator (double pipe ||).

I tried the following which works,

procedure dynamic(table_name IN VARCHAR2)
...

dbms_sql.parse(cursor_id, 'select a_column from ' || table_name , dbms_sql.native);
...

But when I want to use the table-name in a where-clause, I have to use the bind_variable-procedure
in order to get the procedure to work.

procedure dynamic(table_name IN VARCHAR2)
...

dbms_sql.parse(cursor_id, 'select a_column from a_table where
some_column = :x', dbms_sql.native);
dbms_sql.bind_variable(cursor_id, ':x', table_name);

This works fine, too.
The question now is, why do I have to use the double-pipe in the procedure dynamic and why doesn't this work in procedure dynamic2?

Please cc me as I don't always have the possibilty to read this newsgroup.

Thanks a lot,
Marc

--
Marc Eilens, Student
FB Angewandte Informatik, FH Trier
[Applied Computer Science,
Tech. University of Trier, Germany]
mailto: eilensm_at_TriLUG.FH-Trier.de Received on Wed Nov 04 1998 - 03:39:45 CST

Original text of this message

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