Skip to content

22018 — invalid_character_value_for_cast

Source-backed reference for PostgreSQL SQLSTATE 22018.

At a glance

A character value is rejected by the conversion requested by an operation. The fixed PostgreSQL 18.6 catalogue confirms invalid_character_value_for_cast, but the bounded source scan does not bind this entry to one native emitter or message template.

Field Value
SQLSTATE 22018
Condition invalid_character_value_for_cast
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_CHARACTER_VALUE_FOR_CAST
Aliases

Meaning

22018 identifies a character representation that the requested conversion cannot accept. The condition name does not select a target type, parser, locale rule, or wrapper; those details belong to the operation that reports the code. Do not turn this definition into an assertion about one particular cast implementation.

Diagnosis

Read the complete primary, source and target types, input format, and any locale or type-specific setting. Decide whether the input is malformed for the target parser, outside its range, or rejected by type resolution. A date/time syntax diagnostic, a numeric range diagnostic, and a generic operator mismatch can use neighboring codes; the real message and owner decide which repair applies.

Response

Correct the source representation or explicit conversion according to the actual source type, target type, and format rules. If the diagnostic comes from a wrapper or extension, follow that consumer’s documented parser and do not assume the fixed core scan covers it.

Versions

The locked catalogue records this condition from 7.4; fixed source coverage is PostgreSQL 18.6. The exact implementation introduction date and a fixed native emitter remain unresolved by this bounded review.

22007, 22003

Sources

The fixed definition is confirmed in errcodes.txt. Runtime verification is not_run; the bounded PostgreSQL 18.6 scan does not resolve a single native emitting path, so this page does not assert a primary template, severity, or transaction effect. The structured evidence record retains the definition and scope boundary.