Home » SQL & PL/SQL » SQL & PL/SQL » Please, Help with Dynamic sql with BULK INTO
Please, Help with Dynamic sql with BULK INTO [message #20515] Fri, 31 May 2002 04:21 Go to next message
Valcindor
Messages: 2
Registered: May 2002
Junior Member
Could you please help me with the following.
I have this procedure that does not work.

procedure test
IS
TYPE cursor_toto IS REF CURSOR;
TYPE NameList IS TABLE OF td_toto.toto_col%TYPE;
names NameList;
c1 cursor_toto;
v_select varchar2(2000);

BEGIN
v_select :='select distinct toto_col from td_toto';

OPEN c1 FOR v_select;

FETCH c1 BULK COLLECT INTO names;
IF c1%NOTFOUND THEN
...some code
END IF;

.. some other code
CLOSE c1;
END TEST;

I get the following error : ORA-01001: invalid cursor !!

But if I replace
OPEN c1 FOR v_select;
by
OPEN c1 FOR 'select distinct toto_col from td_toto';
I get the result I expect.
Re: Please, Help with Dynamic sql with BULK INTO [message #20520 is a reply to message #20515] Fri, 31 May 2002 10:03 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
You cannot use a weak ref cursor with BULK COLLECT. See this link for a workaround:

http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:1380203556717
Previous Topic: Counting unique values in a table
Next Topic: trigger
Goto Forum:
  


Current Time: Tue May 21 11:03:05 CDT 2024