I have a query which can return 0,1, or more rows.
This is my function:
CREATE OR REPLACE FUNCTION A(v_x integer)
RETURNS void AS
select a,b,sum(qty) into x_part, x_part2,x_sum
where location= any (v_x)
group by a,b
..... more actions....
LANGUAGE plpgsql VOLATILE
I have two problems:
- if the query return more than one row I can not save the result into x_part,x_part2,x_sum.
- How can I tell the number of rows returned?
Basically what I need is if there is more than 1 row to get out of the function with error msg, if there is 1 or 0 rows.. keep going with the function operation.
How do I do that?