Index_by表 集合类型

Index_by表 集合类型
DECLARE
TYPE T_RECOR IS record(fid varchar2(12),name varchar2(20));
TYPE T_TABLE IS TABLE OF T_RECOR index by VARCHAR2(2);
--BINARY_INTEGER;
V_TABLE T_TABLE;
V_RECOR T_RECOR;
slen varchar2(2) := '1a';
--slen number;
BEGIN
--SELECT fid,name INTO V_RECOR FROM tableb where fid='1';
--V_TABLE(1) := V_RECOR;
V_RECOR.fid := '02';
V_RECOR.name := 'qss';
V_TABLE(slen) := V_RECOR;
--DBMS_OUTPUT.PUT_LINE(V_TABLE.COUNT);
--while slen <= V_TABLE.count
--loop
--DBMS_OUTPUT.PUT_LINE(V_TABLE(slen).fid);
--DBMS_OUTPUT.PUT_LINE(V_TABLE(slen).name);
DBMS_OUTPUT.PUT_LINE(V_TABLE(slen).fid);
DBMS_OUTPUT.PUT_LINE(V_TABLE(slen).name);
--slen :=slen+1;
--end loop;
END;



DECLARE
TYPE T_RECOR IS record(fid varchar2(12),name varchar2(20));
TYPE T_TABLE IS TABLE OF T_RECOR index by binary_integer;
--BINARY_INTEGER;
V_TABLE T_TABLE;
V_RECOR T_RECOR;
slen number:=1;
--slen number;
BEGIN
SELECT fid,name INTO V_RECOR FROM tableb where fid='1';
V_TABLE(1) := V_RECOR;
V_RECOR.fid := '02';
V_RECOR.name := 'qss';
V_TABLE(slen) := V_RECOR;
DBMS_OUTPUT.PUT_LINE(V_TABLE.COUNT);
while slen <= V_TABLE.count
loop
DBMS_OUTPUT.PUT_LINE(V_TABLE(slen).fid);
DBMS_OUTPUT.PUT_LINE(V_TABLE(slen).name);
DBMS_OUTPUT.PUT_LINE(V_TABLE(slen).fid);
DBMS_OUTPUT.PUT_LINE(V_TABLE(slen).name);
slen :=slen+1;
end loop;
END;




declare
type table1 is record(fid varchar2(10),username varchar2(20));
type table2 is table of table1 index by varchar2(2);
v_table1 table1;
v_table2 table2;
begin
   select b.fid,b.name into v_table1 from tableb b where b.fid='1';
   v_table2('ab') :=v_table1;
   v_table1.fid:='123';
   v_table1.username:='linhua';
   v_table2('ac'):=v_table1;

  DBMS_OUTPUT.PUT_LINE(v_table2('ab').fid);
  DBMS_OUTPUT.PUT_LINE(v_table2('ab').username);
   DBMS_OUTPUT.PUT_LINE(v_table2('ac').fid);
   DBMS_OUTPUT.PUT_LINE(v_table2('ac').username);
end;



declare
type table1 is record(fid varchar2(10),username varchar2(20));
type table2 is table of table1 index by binary_integer;
v_table1 table1;
v_table2 table2;
slen number :=1;
begin
   select b.fid,b.name into v_table1 from tableb b where b.fid='1';
   v_table2(1) :=v_table1;
   v_table1.fid:='123';
   v_table1.username:='linhua';
   v_table2(2):=v_table1;

  while slen <= v_table2.count
  loop
  DBMS_OUTPUT.PUT_LINE(v_table2(slen).fid);
  DBMS_OUTPUT.PUT_LINE(v_table2(slen).username);
   slen :=slen+1;
   end loop;
end;





你可能感兴趣的:(index)