create or replace function "updateTable_with_fetch"(limitid integer) returns integer LANGUAGE 'plpgsql' COST 100 VOLATILE PARALLEL SAFE AS $BODY$ declare Tid integer; declare cur_update cursor for select lt."TransactionId" from public."LastTransactions" lt inner join "Transactions" t on t."Id" =lt."TransactionId" where t."IsActive" =false LIMIT limitid; begin -- open the cursor open cur_update;
loop -- fetch row into the film fetch cur_update into Tid; -- exit when no more row to fetch exit when not found;
-- build the output /* update "Transactions" set "IsActive"=true where "Id" = Tid; */ raise notice 'Value: %', Tid; end loop;
-- close the cursor close cur_update; end; $BODY$;