要声明关联数组,需要先声明一个关联数组类型,然后声明这个类型的一个变量。最简单的语法格式如下:

    1. TYPE array_type IS TABLE OF element_type INDEX BY key_type;
    2. array_name array_type;

    示例:声明关联数组

    1. delimiter /
    2. DECLARE
    3. -- 声明关联数组,不带游标
    4. TYPE TYPE_WARE IS TABLE OF ware%ROWTYPE INDEX BY PLS_INTEGER ;
    5. wares TYPE_WARE;
    6. TYPE TYPE_WARE_NAME IS TABLE OF ware.w_name%TYPE INDEX BY ware.w_id%TYPE;
    7. ware_names TYPE_WARE_NAME;
    8. BEGIN
    9. NULL;
    10. END;
    11. /
    12. delimiter ;