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 -> Re: PL/SQL Table question

Re: PL/SQL Table question

From: jane <janeyiu_at_optonline.net>
Date: Tue, 20 Nov 2001 16:27:38 GMT
Message-ID: <_vvK7.164571$%94.29435247@news02.optonline.net>


What do you mean by
>"...a PL/SQL table (from a stored procedure)
>as it was a ordinary database table............." ???

The first thing about PL/SQL Table is that it is NOT an ordinary database table, that exists in the data dictionary and your datafiles, PL/SQL Table exists only in PL/SQL blocks, in memory.

> prosjekt.navnTYPE);

is wrong....should be: prosjekt.navn%TYPE);

> select sum_tab FROM Dual;

You can't just fire a query like this within PL/SQL. What do you want it to do ? Check your PL/SQL book on proper usage of SQL.

--this will show you the content of your sum_tab PL/SQL Table. FOR i IN sum_tab.FIRST..sum_tab.LAST
LOOP
 ---do whatever.....
 dbms_output.put_line(sum_tab(i).v_prosjekt_id||' '||sum_tab(i).v_navn); END LOOP; hth
jane

> I need to return data stored in a PL/SQL table (from a stored procedure)
> as it was a ordinary database table. I was thinking of using a method
like:
>
> But it doesn't seem to work:
> DECLARE
>
> TYPE type_sum_rec IS RECORD (v_prosjekt_id number(10), v_navn
> prosjekt.navnTYPE);
>
> TYPE type_sum_tab IS TABLE OF type_sum_rec INDEX BY BINARY_INTEGER;
>
>
> sum_tab type_sum_tab;
>
> BEGIN
>
> sum_tab(1).v_prosjekt_id := 1;
>
> sum_tab(1).v_navn := 'test';
>
> sum_tab(2).v_prosjekt_id := 2;
>
> sum_tab(2).v_navn := 'olaf';
>
>
> select sum_tab FROM Dual;
>
>
> END;
>
Received on Tue Nov 20 2001 - 10:27:38 CST

Original text of this message

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