FOR UPDATE and WHERE CURRENT OF
ExplanationOracle Fusion / EBS · Technical · PL/SQLHigh confidenceGenerated
FOR UPDATE locks the fetched rows; WHERE CURRENT OF updates or deletes the row the cursor is positioned on.
How it works
Declaring a cursor with SELECT ... FOR UPDATE [OF col] locks every selected row when the cursor opens, holding the locks until COMMIT or ROLLBACK — so keep the transaction short. Inside the loop, UPDATE/DELETE ... WHERE CURRENT OF cursor_name targets exactly the current row without repeating the key predicate. Add FOR UPDATE SKIP LOCKED to step over rows another session already locked (a simple queue pattern), or NOWAIT to fail fast instead of blocking.
How it works
DECLARE
CURSOR c_ap IS
SELECT invoice_id, amount
FROM ap_invoices_all
WHERE process_flag = 'N'
FOR UPDATE SKIP LOCKED;
BEGIN
FOR r IN c_ap LOOP
UPDATE ap_invoices_all
SET process_flag = 'Y', processed_on = SYSDATE
WHERE CURRENT OF c_ap;
END LOOP;
COMMIT;
END;
/Related questions
GroundingGenerated
Model-generated, grounded against the curated knowledge layer. Check specifics against your instance.