要声明关联数组,需要先声明一个关联数组类型,然后声明这个类型的一个变量。最简单的语法格式如下:
TYPE array_type IS TABLE OF element_type INDEX BY key_type;
array_name array_type;
示例:声明关联数组
delimiter /
DECLARE
-- 声明关联数组,不带游标
TYPE TYPE_WARE IS TABLE OF ware%ROWTYPE INDEX BY PLS_INTEGER ;
wares TYPE_WARE;
TYPE TYPE_WARE_NAME IS TABLE OF ware.w_name%TYPE INDEX BY ware.w_id%TYPE;
ware_names TYPE_WARE_NAME;
BEGIN
NULL;
END;
/
delimiter ;