DEFINITIONS

Definitions More Info.
Definition ID12.074
TitlePOSTGRESQL
CategoryNOTES
DefinitionCURSOR FETCH FUNCTION EXAMPLE ORNEK
Definition Descriptioncreate 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$;

SELECT "updateTable_with_fetch"(10)
RecordBycunay
Record Date20-05-2022 00:03:37
Düzenle
Kopyala
Sil