1.存储过程中如何自定义一个数组,下面这个是最优的 1.1直接调用 DECLARE TYPE months_varray IS VARRAY(12) OF STRING(9 CHAR); arr MONTHS_VARRAY := months_varray('January','February','March' ,'April','May','June' ,'July','August','September' ,'October','November','December'); TYPE calendar_table IS TABLE OF VARCHAR2(9 CHAR) INDEX BY BINARY_INTEGER; calendar CALENDAR_TABLE;
begin for i in arr.first..arr.last loop DBMS_OUTPUT.PUT_LINE(arr(i)); calendar(i):=arr(i); end loop;
DBMS_OUTPUT.PUT_LINE('=========='); for i in calendar.first..calendar.last loop DBMS_OUTPUT.PUT_LINE(calendar(i)); end loop; end;
1.2生成存储过程,然后被调用 create or replace procedure p_test as type t_Test is table of varchar2(10); test t_test:=t_test('A','B','C','D','E','F','G','H','J','K','L'); begin for i in test.first .. test.last loop dbms_output.put_line(test(i)); end loop; end; |
|