Jump to content

Recommended Posts

Posted

Oka pl/sql nested table collection undi. Say,
TYPE loc_tab IS TABLE OF (one VARCHAR2(10), two NUMBER);
tab1 loc_tab;

I created a global type with same structure as of loc_tab.
CREATE TYPE r_Glob IS OBJECT OF ((one VARCHAR2(10), two NUMBER);
CREATE TYPE t_Glob IS TABLE OF r_Glob;
tab2 t_Glob := t_Glob(); --Initilase

Now, I have data in tab1. How to populate the same data in tab2. I tried in several ways, but always ending up with this error:
ORA-06531: Error at line2, Reference to unninitialised collection.

I did like this.

line1: FOR x IN tab1.FIRST..tab1.LAST LOOP
line2:tab2.EXTEND; (or tab2.EXTEND(1) tried both ways)
line3:tab2(x).one := tab1(x).one;
line4:tab2(x).two := tab1(x).two;
line5:END LOOP;

Koncham help cheyyandi..

Posted

babai nuvvu rendu types ni equate cheyaali ani anukuntunnavu??? reason yeenti yee req ki nuvvu aa code conclusion (rendu types create cheesi malla oka danini inkooo daniki euate cheyali ani) ki vachhavu???....
nuvvu oka type loo unna value ni alaa assign cheeya leevu..
nuvvu cheesina daantloo type create ayyindhi kaani daantloo data yeemi leedhu kooda as you didn't inserted anything into it... (table type vere and object type vere in object type nuvvu insert cheyali)
Inkooti as long as you were not creating a type with in a stored procedure, it is a global type and can be used in any stored procedure..

Suppose neeku oka Table_x ani undhi.. it has columns by name one, asd,dfg or what ever then see the below code...


CREATE TYPE r_Glob IS OBJECT (one VARCHAR2(10), two NUMBER); -- creating a type.
CREATE TYPE t_Glob IS TABLE OF r_Glob; -- creating a nested table type.

declare
-- Declaring the variables for the Stored Procedure
r_glob_proc r_glob;
t_glob_proc t_glob;
begin
r_glob_proc := r_glob('AP 21T 007', 9999); -- Assigning the values to the Type
t_glob_proc := t_glob(r_glob_proc); -- Assigning the values to nested table type

for r in (select i.*
from table_x i, TABLE(t_glob_proc) rt
where i.one = rt.one) loop
-- your code here
end loop;
end;
[color=#ff0000][b][size=4]Also going forward vesee technical questions ni Learning section loo veeyandi instead of mixing them with the Discussion and all other sections it would be easy to all to track and answer ...[/size][/b][/color]

×
×
  • Create New...