如何在oracle建一个存储过程来遍历数组,新手求解

怎么在oracle建一个存储过程来遍历数组,新手求解建一个存储过程定义一个一维数组 Test{A,B,C,D,E,F,G,H,J,

怎么在oracle建一个存储过程来遍历数组,新手求解
建一个存储过程
定义一个一维数组 Test{A,B,C,D,E,F,G,H,J,K,L}
怎么样用循环遍历数组,然后输出

新手求解

[解决办法]

SQL code
create or replace procedure p_test astype t_Test is table of varchar2(10);test t_test:=t_test('A','B','C','D','E','F','G','H','J','K','L');beginfor i in test.first .. test.last loopdbms_output.put_line(test(i));end loop;end;/set serverout onexec p_test;---------------------ABCDEFGHJKLPL/SQL procedure successfully completed.
[解决办法]
探讨

SQL code
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
dbm……

[解决办法]
SQL code
DECLARE  -- Define a varray of twelve strings.  TYPE months_varray IS VARRAY(12) OF STRING(9 CHAR);     -- Define an associative array of strings.  TYPE calendar_table IS TABLE OF VARCHAR2(9 CHAR)    INDEX BY BINARY_INTEGER;  -- Declare and construct a varray.  month MONTHS_VARRAY :=     months_varray('January','February','March'                 ,'April','May','June'                 ,'July','August','September'                 ,'October','November','December');  -- Declare an associative array variable.  calendar CALENDAR_TABLE;BEGIN  -- Check if calendar has no elements.  IF calendar.COUNT = 0 THEN    -- Print a title    DBMS_OUTPUT.PUT_LINE('Assignment loop:');    DBMS_OUTPUT.PUT_LINE('----------------');    -- Loop through all the varray elements.    FOR i IN month.FIRST..month.LAST LOOP      -- Initialize a null associative array element.      calendar(i) := '';      -- Print an indexed element from the associative array.      DBMS_OUTPUT.PUT_LINE(        'Index ['||i||'] is ['||calendar(i)||']');      -- Assign the numeric index valued varray element      -- to an equal index valued associative array element.      calendar(i) := month(i);    END LOOP;    -- Print a title    DBMS_OUTPUT.PUT(CHR(10));    DBMS_OUTPUT.PUT_LINE('Post-assignment loop:');    DBMS_OUTPUT.PUT_LINE('---------------------');    -- Loop through all the associative array elements.    FOR i IN calendar.FIRST..calendar.LAST LOOP      -- Print an indexed element from the associative array.      DBMS_OUTPUT.PUT_LINE(        'Index ['||i||'] is ['||calendar(i)||']');    END LOOP;  END IF;END;
我的异常网推荐解决方案:oracle存储过程,http://www.myexception.cn/oracle-develop/177537.html