云数据库 GAUSSDB-赋值语句:示例

时间:2024-11-02 18:48:31

示例

openGauss=# DECLARE
    my_id integer;
BEGIN
    select id into my_id from customers limit 1; -- 赋值
END;
/

openGauss=# 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;
/

BULK COLLECT INTO 只支持批量赋值给数组。合理使用LIMIT字段避免操作过量数据导致性能下降。

support.huaweicloud.com/distributed-devg-v2-gaussdb/gaussdb_v5r2c10_0637.html