declare
v_count number := 1000000;
v_rnd number := 0;
ii varchar2(128);
v_dummy_vc2 varchar2(32767);
v_dummy_nr number;
v_dummy_dt date;
c_VC2_TYPE constant varchar2(1) := 'V';
c_NR_TYPE constant varchar2(1) := 'N';
c_DT_TYPE constant varchar2(1) := 'D';
type r_my_data_type is record (
type varchar2(1),
vc2 varchar2(32767),
nr number,
dt date);
type t_my_data_type is table of r_my_data_type index by varchar2(128);
t_my_data t_my_data_type;
procedure set_mydata(p_idx in varchar2, p_vc2 in varchar2) as
begin
t_my_data(p_idx).type := c_VC2_TYPE;
t_my_data(p_idx).vc2 := p_vc2;
end set_mydata;
procedure set_mydata(p_idx in varchar2, p_nr in number) as
begin
t_my_data(p_idx).type := c_NR_TYPE;
t_my_data(p_idx).nr := p_nr;
end set_mydata;
procedure set_mydata(p_idx in varchar2, p_dt in date) as
begin
t_my_data(p_idx).type := c_DT_TYPE;
t_my_data(p_idx).dt := p_dt;
end set_mydata;
begin
help.out('=== MYDATA VARCHAR2 ===');
-- help.mem;
help.b;
for i in 1 .. v_count loop
v_rnd := mod(i, 3);
case v_rnd
when 0 then set_mydata(to_char(i), 'test ' || i);
when 1 then set_mydata(to_char(i), to_number((i + v_rnd)));
when 2 then set_mydata(to_char(i), to_date((sysdate - (i/10))));
else help.out('???');
end case;
end loop I;
help.i('fill mydata');
ii := t_my_data.first;
while ii is not null loop
case t_my_data(ii).type
when c_VC2_TYPE then v_dummy_vc2 := t_my_data(ii).vc2;
when c_NR_TYPE then v_dummy_nr := t_my_data(ii).nr;
when c_DT_TYPE then v_dummy_dt := t_my_data(ii).dt;
end case;
ii := t_my_data.next(ii);
end loop II;
help.i('loop mydata');
help.e;
help.show;
-- help.mem;
end;