Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> How to bind collection using dbms_sql in Oracle 9iR2?
In static sql I can open a select cursor that uses a collection type
create or replace type numbers as table of number
/
declare
list numbers := numbers(1,2,3,4,5,6,7,8,9,10);
begin
for f in (select dba_objects.object_id from dba_objects
where dba_objects.object_id in
(select column_value as object_id from
table(cast(list as numbers)))) loop
null; -- do something
end loop;
end;
/
How is it possible to do bind collection type using dbms_sql?
declare
list numbers := numbers(1,2,3,4,5,6,7,8,9,10);
txt varchar2(4000) := 'select dba_objects.object_id from '||
'dba_objects where dba_objects.object_id in '||
'(select column_value as object_id '|| ' from table(cast(:1 as numbers)))';hnd integer := dbms_sql.open_cursor;
dbms_sql.parse( hnd, txt, dbms_sql.native ); dbms_sql.define_column( hnd, 1, val ); dbms_sql.bind_variable( hnd, ':1', list );-- ^^ this line causes PLS-00306, which is - -- "wrong number or types of arguments"
I know that bind_variable( <integer>, <varchar2>, <collection> ) does not exist. I wonder if anybody managed to find a workaround?
Please help,
Many Thanks,
Alex
Received on Thu Apr 03 2003 - 07:24:02 CST
![]() |
![]() |