Look at this simple PL/pgSQL function:
create or replace function test() returns void()
as $$
declare
a int;
begin
select more_than_one_value into a from my_table;
-- do some other job using a
end;
$$
language plpgsql;
When calling this function, only one row is selected because select into
pass only one value to a
, even though column more_than_one_value
has many values.
Are there any convenient ways to select many values from a table and then assigned them to variable a
? I know create temp table as select
is one method. I am looking for alternatives.