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 -> How do I bind variables to dynamic SQL?

How do I bind variables to dynamic SQL?

From: <dperez_at_juno_nospam.com>
Date: Thu, 02 Sep 1999 01:43:47 GMT
Message-ID: <37cdd303.86458540@news.uswest.net>


I have an anonymous block that reads from a table.

I need to bind 2 variables. One is a single integer value for the app_id. This

works FINE. The other is a series of integers of undetermined length, each of which relates to a single record... In standard sql the query would look like:

select * from xxx where col1 in (123,456,789);

In dynamic sql this WORKS FINE when the code looks like:

DBMS_SQL.PARSE(Fingerprint_Cursor,
'SELECT Object_ID, Object_Type, Name, File_Size, Path, Status, Finger_print ' ||

'FROM Ec_App_Sets A, Ec_Files B ' ||
'WHERE A.APP_ID = :app_id ' ||

       ' AND A.OBJECT_ID in (' || object_list || ' )'
       , DBMS_SQL.NATIVE); 

When object_list is a varchar2 loaded with '123,456,789'

Again, this worked ABSOLUTELY PERFECTLY. Except that since the variable isn't bound, and object list changes every time the routine is run, it caused hundreds of queries to get created......... SO, the question, HOW DO I BIND A SET OF VALUES THAT CAN BE USED IN AN "IN" PREDICATE? The string of comma-delimited integers MUST remain intact. Parsing it, and creating a varying number of predicates would NOT solve the problem. Thus far, I can bind a SINGLE integer and use it in the "IN" but when I do the same with a string as above it APPEARS that SQL treats it as a SINGLE value (the SAME WAY the static SQL does) instead of recognizing it as a series. Ideas? Received on Wed Sep 01 1999 - 20:43:47 CDT

Original text of this message

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