i'm quite new to postgre. i want to create function (like stored procudure) that update multiple rows and select those affected rows out
here is my statement
CREATE or replace FUNCTION set_val(
_val character varying(100) ) --5
RETURNS setof "table_test" AS
$body$
declare results "table_test"%rowtype;
begin
update "table_test"
set "value" = $1
where "gender" = 'm'
returning * into results;
if not found then
insert into "table_test"("value")
values($1)
returning * into results;
end if;
return next results;
end;
$body$
LANGUAGE 'plpgsql' ;
its work fine when only 1 row was affected. but if there is more than 1 rows affected, this finction is not working