Home » SQL & PL/SQL » SQL & PL/SQL » Initializing a plsql table
Initializing a plsql table [message #2253] Tue, 02 July 2002 02:54
Alex
Messages: 190
Registered: August 1999
Senior Member
I'm trying to build a function that returns a table with the elements of a cursor...

But how can I initialiez this table ? I do not know how many rows there will be....

tab ttab := ttab(tobj(null,null)) ; i can insert 1 row
tab ttab := ttab() ; i can't insert any row

any help appreciated

create or relace type tobj as object(cle number, nom varchar2(128));
create or replace type ttab is table of tobj;

CREATE OR REPLACE FUNCTION testfunc Return ttab IS

cursor CUR is select ARTICLE_CLE, ARTICLE_LIBELLE from ARTICLES where TVA_CLE=2;
tab ttab := ttab(tobj(null,null)) ;
i integer :=0;

BEGIN
for CUR_VAL in CUR loop
tab(i).cle := CUR_VAL.ARTICLE_CLE;
tab(i).nom := CUR_VAL.ARTICLE_LIBELLE;
i:=i+1;

end loop;
close CUR;
RETURN tab;

END testfunc;
/
Previous Topic: Oracle 8i and 8.0
Next Topic: How to add Quotes while inserting a record
Goto Forum:
  


Current Time: Thu Apr 25 16:41:10 CDT 2024