I don't know PG, so I can't answer Daryl's question. However, regarding the Oracle code, note that the cursor's query is executed when you open the cursor, not when you fetch from it (FYI, this is documented in Oracle's PL/SQL User's Guide and Reference). So it's normal that the cursor retrieves the rows from the table even if they've been deleted immediately after the open
statement.