将存储过程内语句返回的值存储到变量内,BULK COLLECT INTO允许将部分或全部返回值暂存到数组内部。
示例:
gbase=# DECLARE
my_id integer;
BEGIN
select id into my_id from customers limit 1; -- 赋值
END;
/
gbase=# DECLARE
type id_list is varray(6) of customers.id%type;
id_arr id_list;
BEGIN
select id bulk collect into id_arr from customers order by id DESC limit 20; -- 批量赋值
END;
/