The following table lists all the defined error codes. Some are not used, but are defined by the SQL standard. The error classes are also shown. For each error class there is a standard error code having the last three characters 000. This code is used only for error conditions that fall within the class but do not have any more-specific code assigned.
The PL/pgSQL condition name for each error code is the same as the phrase shown in the table, with underscores substituted for spaces. For example, code 22012, DIVISION BY ZERO, has condition name DIVISION_BY_ZERO. Condition names can be written in either upper or lower case.
Note: PL/pgSQL does not recognize warning, as opposed to error, condition names; those are classes 00, 01, and 02.
Error Code
Meaning
Constant
Class 00— Successful Completion
02001
NO ADDITIONAL DYNAMIC RESULT SETS RETURNED
no_additional_dynamic_result_sets_returned
Class 03 — SQL Statement Not Yet Complete
08001
SQLCLIENT UNABLE TO ESTABLISH SQLCONNECTION
sqlclient_unable_to_establish_sqlconnection
08004
SQLSERVER REJECTED ESTABLISHMENT OF SQLCONNECTION
sqlserver_rejected_establishment_of_sqlconnection
08007
TRANSACTION RESOLUTION UNKNOWN
transaction_resolution_unknown
08P01
PROTOCOL VIOLATION
protocol_violation
Class 09 — Triggered Action Exception
2201G
INVALID ARGUMENT FOR WIDTH BUCKET FUNCTION
invalid_argument_for_width_bucket_function
22018
INVALID CHARACTER VALUE FOR CAST
invalid_character_value_for_cast
22007
INVALID DATETIME FORMAT
invalid_datetime_format
22019
INVALID ESCAPE CHARACTER
invalid_escape_character
2200D
INVALID ESCAPE OCTET
invalid_escape_octet
22025
INVALID ESCAPE SEQUENCE
invalid_escape_sequence
22P06
NONSTANDARD USE OF ESCAPE CHARACTER
nonstandard_use_of_escape_character
22010
INVALID INDICATOR PARAMETER VALUE
invalid_indicator_parameter_value
22020
INVALID LIMIT VALUE
invalid_limit_value
22023
INVALID PARAMETER VALUE
invalid_parameter_value
2201B
INVALID REGULAR EXPRESSION
invalid_regular_expression
22009
INVALID TIME ZONE DISPLACEMENT VALUE
invalid_time_zone_displacement_value
2200C
INVALID USE OF ESCAPE CHARACTER
invalid_use_of_escape_character
2200G
MOST SPECIFIC TYPE MISMATCH
most_specific_type_mismatch
22004
NULL VALUE NOT ALLOWED
null_value_not_allowed
22002
NULL VALUE NO INDICATOR PARAMETER
null_value_no_indicator_parameter
22003
NUMERIC VALUE OUT OF RANGE
numeric_value_out_of_range
22026
STRING DATA LENGTH MISMATCH
string_data_length_mismatch
22001
STRING DATA RIGHT TRUNCATION
string_data_right_truncation
22011
SUBSTRING ERROR
substring_error
22027
TRIM ERROR
trim_error
22024
UNTERMINATED C STRING
unterminated_c_string
2200F
ZERO LENGTH CHARACTER STRING
zero_length_character_string
22P01
FLOATING POINT EXCEPTION
floating_point_exception
22P02
INVALID TEXT REPRESENTATION
invalid_text_representation
22P03
INVALID BINARY REPRESENTATION
invalid_binary_representation
22P04
BAD COPY FILE FORMAT
bad_copy_file_format
22P05
UNTRANSLATABLE CHARACTER
untranslatable_character
Class 23 — Integrity Constraint Violation
25003
INAPPROPRIATE ACCESS MODE FOR BRANCH TRANSACTION
inappropriate_access_mode_for_branch_transaction
25004
INAPPROPRIATE ISOLATION LEVEL FOR BRANCH TRANSACTION
inappropriate_isolation_level_for_branch_transaction
25005
NO ACTIVE SQL TRANSACTION FOR BRANCH TRANSACTION
no_active_sql_transaction_for_branch_transaction
25006
READ ONLY SQL TRANSACTION
read_only_sql_transaction
25007
SCHEMA AND DATA STATEMENT MIXING NOT SUPPORTED
schema_and_data_statement_mixing_not_supported
25P01
NO ACTIVE SQL TRANSACTION
no_active_sql_transaction
25P02
IN FAILED SQL TRANSACTION
in_failed_sql_transaction
Class 26 — Invalid SQL Statement Name
2B000
DEPENDENT PRIVILEGE DESCRIPTORS STILL EXIST
dependent_privilege_descriptors_still_exist
2BP01
DEPENDENT OBJECTS STILL EXIST
dependent_objects_still_exist
Class 2D — Invalid Transaction Termination
40002
TRANSACTION INTEGRITY CONSTRAINT VIOLATION
transaction_integrity_constraint_violation
40001
SERIALIZATION FAILURE
serialization_failure
40003
STATEMENT COMPLETION UNKNOWN
statement_completion_unknown
40P01
DEADLOCK DETECTED
deadlock_detected
Class 42 — Syntax Error or Access Rule Violation