2014-12-04 70 views
0

我有一個關聯數組聲明,在我嘗試調試的過程中,我需要在調試器中初始化該數組,但我似乎無法弄清楚正確初始化字符串在Sql Developer調試器中初始化Oracle關聯數組

這裏是調試塊:

DECLARE 
    I_COMPONENTS_ARRAY PKG_CLASSIFICATION_MATRIX.T_NUMBER_ASSOC_ARRAY := T_NUMBER_ASSOC_ARRAY('544679','512477'); 
    I_QUESTION_ID NUMBER; 
    I_ANSWER_BOOLEAN NUMBER; 
    O_UPDATE_INFO sys_refcursor; 
BEGIN 
    --Modify the code to initialize the variable 
    --I_COMPONENTS_ARRAY := NULL; 

    --THESE ARE MY ATTEMPTS AT INITIALIZATION 
    --I_COMPONENTS_ARRAY('1') := 544679; 
    --I_COMPONENTS_ARRAY('2') := 512477; 
    --I_COMPONENTS_ARRAY := PKG_CLASSIFICATION_MATRIX.T_NUMBER_ASSOC_ARRAY(544679,512477); 

    I_QUESTION_ID := NULL; 
    I_ANSWER_BOOLEAN := NULL; 

    PKG_CLASSIFICATION_MATRIX.UPDATE_COLUMN(
    I_COMPONENTS_ARRAY => I_COMPONENTS_ARRAY, 
    I_QUESTION_ID => I_QUESTION_ID, 
    I_ANSWER_BOOLEAN => I_ANSWER_BOOLEAN, 
    O_UPDATE_INFO => O_UPDATE_INFO 
); 
/* Legacy output: 
DBMS_OUTPUT.PUT_LINE('O_UPDATE_INFO = ' || O_UPDATE_INFO); 
*/ 
:O_UPDATE_INFO := O_UPDATE_INFO; --<-- Cursor 
--rollback; 
END; 

我我做錯了什麼,或者是無法初始化在時尚的陣列?

這裏是陣列中的包裝規格聲明:

TYPE T_NUMBER_ASSOC_ARRAY IS TABLE OF NUMBER INDEX BY PLS_INTEGER; 

回答

1

試試這個,

declaration of the array in the package spec: 
TYPE T_NUMBER_ASSOC_ARRAY IS TABLE OF NUMBER INDEX BY PLS_INTEGER; 

debugger block: 
I_COMPONENTS_ARRAY PKG_CLASSIFICATION_MATRIX.T_NUMBER_ASSOC_ARRAY; 

begin 
I_COMPONENTS_ARRAY (1) := 'Value1'; 
I_COMPONENTS_ARRAY (2) := 'Value2'; 
. 
. 
. 
I_COMPONENTS_ARRAY (n) := 'ValueN'; 
end; 

因爲你的陣列是NUMBER INDEX BY PLS_INTEGER表,你不能這樣做I_COMPONENTS_ARRAY(」 1')

相關問題