2014-01-09 94 views
0

你能告訴我爲什麼這不起作用嗎?我想在嵌套表A,B添加一個值,C使用索引的先行嵌套表格是記錄和嵌套表格

PL/SQL

TYPE chars is table of varchar2(30); 
TYPE numbers is table of number; 
TYPE t_content IS RECORD(a numbers, b chars, c chars); 
TYPE t_table IS table of t_content index by varchar2(30); 
v_information t_table; 

內。然後在宣告

v_information ('Index1').a:= numbers(); 

我無法訪問裏面的表a,b,c使用索引值表。哪裏不對?

+0

什麼是錯誤您收到?剩下的代碼是什麼? – Rachcha

回答

0

首先聲明一個記錄變量。

嘗試:

DECLARE 
    TYPE chars is table of varchar2(30) ; 
    TYPE numbers is table of number ; 
    TYPE t_content IS RECORD(a numbers, b chars, c chars) ; 
    TYPE t_table IS table of t_content index by varchar2(30) ; 
    v_information t_table; 
    my_record t_content; 
BEGIN 
    my_record.a := numbers(1,2,3,4); 
    my_record.b := chars('a','b','c'); 
    my_record.c := chars('x','y','z'); 
    v_information('Index1') := my_record; 

    my_record.a := numbers(22,44); 
    my_record.b := chars('aa','bb','cc'); 
    my_record.c := chars('x','y'); 
    v_information('Index2') := my_record; 
END; 
/

演示: