日期:2014-05-16  浏览次数:20516 次

Oracle定义联合数组

-- Created on 2010/04/15 by NAN
declare
  -- Local variables here
  i integer;
  v_kbis kbis% ROWTYPE;
  TYPE t_table IS TABLE OF kbis% ROWTYPE INDEX BY BINARY_INTEGER;-- 定义联合数组(不需要初始化)
  v_t_table t_table;
begin
  -- Test statements here
  v_kbis.k001 := '1';
  v_t_table(1) := v_kbis;
  v_kbis.k001 := '2';
  v_t_table(2) := v_kbis;

  FOR i IN 1 ..v_t_table.count LOOP
      dbms_output.put_line(v_t_table(i).k001);
  END LOOP;

  EXCEPTION
  WHEN OTHERS THEN
       dbms_output.put_line( sqlerrm);
end;

[/code