declare
v_count number := 1000000;
v_rnd number := 0;
ii varchar2(128);
type anydata_type is table of anydata index by varchar2(128);
t_ad anydata_type;
v_dummy_type anytype;
v_dummy_vc2 varchar2(32767);
v_dummy_nr number;
v_dummy_dt date;
v_dummy_rc pls_integer;
begin
help.out('=== ANYDATA VARCHAR2 ===');
-- help.mem;
help.b;
for i in 1 .. v_count loop
v_rnd := mod(i, 3);
case v_rnd
when 0 then t_ad(to_char(i)) := anydata.convertVarchar2('test ' || i);
when 1 then t_ad(to_char(i)) := anydata.convertNumber(i + v_rnd);
when 2 then t_ad(to_char(i)) := anydata.convertDate(sysdate - (i*v_rnd));
else help.out('???');
end case;
end loop I;
help.i('fill anydata');
ii := t_ad.first;
while ii is not null loop
case t_ad(ii).getType(v_dummy_type)
when dbms_types.typecode_varchar2 then v_dummy_rc := t_ad(ii).getVarchar2(v_dummy_vc2);
when dbms_types.typecode_number then v_dummy_rc := t_ad(ii).getNumber(v_dummy_nr);
when dbms_types.typecode_date then v_dummy_rc := t_ad(ii).getDate(v_dummy_dt);
end case;
ii := t_ad.next(ii);
end loop II;
help.i('loop GET anydata');
ii := t_ad.first;
while ii is not null loop
case t_ad(ii).getType(v_dummy_type)
when dbms_types.typecode_varchar2 then v_dummy_vc2 := t_ad(ii).accessVarchar2();
when dbms_types.typecode_number then v_dummy_nr := t_ad(ii).accessNumber();
when dbms_types.typecode_date then v_dummy_dt := t_ad(ii).accessDate();
end case;
ii := t_ad.next(ii);
end loop II;
help.i('loop ACCESS anydata');
help.e;
help.show;
-- help.mem;
end;
/