Reputation: 197
In Oracle,
WHEN OTHERS THEN
IF SQLCODE = -31011 THEN
How do I convert the above
IF SQLCODE = -31011 THEN
to Postgres as SQLCODE = -31011
is not compatible with Postgres
Upvotes: 2
Views: 3114
Reputation: 45835
PostgreSQL uses "standardized" SQLSTATE codes. You should to find most near code in the table https://www.postgresql.org/docs/current/errcodes-appendix.html.
You should to prefer named exception if it is available (not available for custom exceptions):
WHEN OTHERS THEN
IF SQLSTATE = '22012' THEN
Upvotes: 2