I want to store multiple values in single variable(array) in postgresql stored procedure.
My query in mysql is as
select name from cloud_table into @cloud; // @cloud contain multiple name
I want to convert this query into Postgresql. how to achieve this.
答案 0 :(得分:0)
You can store all values in an array.
Something like:
....
declare
l_names text[];
begin
...
select array_agg(name)
into l_names
from cloud_table;
-- pass the array to a function
perform some_function(l_names);
...
end;
If you already have a function that accepts an array as a parameter and you want to pass the result of your select as an array, you can use:
select your_function(array(select name from cloud_table));