how to read from the collection .. [message #37467] |
Sun, 10 February 2002 23:50 |
ksr
Messages: 112 Registered: January 2002
|
Senior Member |
|
|
Hi,
i want something like this.
i want to create a type like table (table is already existing).
like
type cur1 is ref cursor;
type cur2 is table of emp%rowtype;
c1 cur1;
c2 cur2;
begin
open c1 for select * from emp;
fetch c1 bulk collect into c2;
close c1;
forall i in c2.first..c2.last
here my doubt.....how to read values from type c2..
insert into t1 values(sequence1.nextval,c2(i)) returning id
------how to read values above
Any help is appreciated
|
|
|
|
Re: how to read from the collection .. [message #37532 is a reply to message #37467] |
Wed, 13 February 2002 07:22 |
ksr
Messages: 112 Registered: January 2002
|
Senior Member |
|
|
The link given by you do not satisfy my requirements..
i want something like...how to create a type of table and how to assign values to it and how to read them.
any help is appreciated
|
|
|
|
Re: how to read from the collection .. [message #37537 is a reply to message #37534] |
Wed, 13 February 2002 07:47 |
andrew again
Messages: 2577 Registered: March 2000
|
Senior Member |
|
|
This uses a pl/sql table which is virtually the same.
-- For sqlplus:
set serveroutput on size 10000
DECLARE
TYPE cat_pltab_type IS TABLE OF cat%ROWTYPE INDEX BY BINARY_INTEGER;
cat_pltab cat_pltab_type;
CURSOR c1 IS SELECT * FROM cat;
i NUMBER;
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO cat_pltab (cat_pltab.COUNT + 1);
EXIT WHEN c1%NOTFOUND;
END LOOP;
FOR i IN 1 .. cat_pltab.COUNT
LOOP
DBMS_OUTPUT.put_line (cat_pltab (i).table_type || ', ' || cat_pltab (i).table_name);
END LOOP;
END;
/
|
|
|