I'm still trying to convert my PL/SQL stored procedures into PL/pgSQL. Now, I have problem with commiting transaction every N rows:
loop fetch csr_ac into row_id; if not FOUND then exit; end if; counter := counter + 1; delete from spm_audit where adt_id=row_id; delete from spm_audit_pipeline_data where apd_adt_id=row_id; global_counter := global_counter + 1; if counter = rows_between_commit then counter := 0; commit; end if; end loop;
I'm digging into postgresql documentation but maybe I'm just not smart enough to understand the way which transactions are being processed into pgSQL. Is it possible to port above code to PL/pgSQL ?