Oracle Array_Example

-- Created on 2010/05/13 by NAN
declare
  -- Local variables here
  i integer;
  v_num PLS_INTEGER DEFAULT 0 ;
  TYPE t_table IS TABLE OF NUMBER;
  v_table t_table;
begin
  -- Test statements here
  v_table := t_table();
  FOR i IN 1 ..10 LOOP
      IF v_table.exists(i) = FALSE THEN
         v_table.extend;
         v_num := v_num + 1;
         v_table(v_num) := i;
      END IF ;
  END LOOP;
 
  FOR i IN v_table.first ..v_table.last + 10 LOOP
      IF v_table.exists(i) = FALSE THEN
         v_table.extend;
         v_num := v_num + 1;
         v_table(v_num) := i;
      END IF ;
  END LOOP;
 
  FOR i IN 1 ..v_table.count LOOP
      dbms_output.put_line(v_table(i));
  END LOOP;
 
  EXCEPTION
      WHEN OTHERS THEN
           dbms_output.put_line( SQLERRM);
end;

你可能感兴趣的:(oracle)