Multiple update statements by getting the data from a subquery inside a stored procedure in Postgresql

R

Rohan Kumar

Guest
I am having issues writing multiple update statements inside a stored procedure based on the data getting from a subquery.

I have tried writing multiple update statements based on some recommendations from Postgresql sources but each time I am getting a syntax error near "update"

create or replace
function public.edit_func(feedid date,
feedidnew date) returns void language plpgsql as $function$
begin
update
sample
set
end_date = '2019-09-08'
where
id = sub.pre
update
sample
set
start_date = '2019-09-09'
where
id = sub.post
from
(
select
(
select
id_new
from
sample
where
col = feedid) as pre,
(
select
id
from
sample
where
col = feedidnew) as post )as sub ;
end;

$function$;

Continue reading...
 
Top