我试图编写以下存储过程 -
Create or replace FUNCTION concat_group_ids()
RETURNS TEXT
AS $function$
DECLARE
curs_group_ids CURSOR FOR SELECT id FROM ad_groups;
result TEXT;
id UUID;
BEGIN
OPEN curs_group_ids;
LOOP
FETCH curs_group_ids INTO id;
result = result || id;
IF NOT FOUND THEN
EXIT;
END IF
END LOOP;
CLOSE curs_group_ids;
return result;
END; $function$
LANGUAGE plpgsql;
但是id与结果的串联不起作用。
运行select concat_group_ids();