Obtain other results status

There are two variables that provide system status indicators: ROW_COUNT and LAST_OID.

  • ROW_COUNT is the number of rows processed by the last SQL query sent down to the SQL engine.
  • LAST_OID is the object ID (oid) of the last row inserted by the most recent SQL query.

LAST_OID is useful only after an INSERT query, and then only when the insert happens on a catalog table. In practice, LAST_OID is not likely to be useful.

In addition to these variables, you can also use the FOUND and IS NULL variables to do special conditional processing based on record results.