user10531062
user10531062

Reputation: 197

SQLCODE in Oracle Equivalent to Postgres

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

Answers (1)

Pavel Stehule
Pavel Stehule

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

Related Questions