When I call pg_errormessage() *after* a transaction block, it doesn't catch any errors which have occurred within, apparently. If I call pg_errormessage() right after the query which throws the error inside the transaction, it catches the error. This is the correct behaviour, or it isn't, according to the definition, depending on how you look at it: ------------------- begin definition ------------------- pg_errormessage() returns a string containing the last error message for given connection. It returns FALSE on failure. ------------------- end definition ------------------- If we take this to mean that pg_errormessage() is overwritten by the last statement in the transaction (that's the impression I get), i.e. pg_exec($conn, "COMMIT WORK;"); which never fails (if the transaction rolls back, it's not handled as an error), then this would mean that in this scenario, pg_errormessage() is pretty useless. I'd want a function that actually returns the last error, wherever it may have occurred within my script. Any opinions, experiences, ideas? Regards, Frank