Diagnostic Queries
Symptoms
A string given where a bigint was expected is not a valid integer. PostgreSQL raises SQLSTATE 22P02 (invalid_text_representation).
- Non-numeric text, decimals, or stray characters in an integer field.
- Common with empty strings or thousands separators.
- The message echoes the offending value.
What the server log shows
ERROR: invalid input syntax for type bigint: "12,345"
Why PostgreSQL raises this — what the manual says
Section 8.1.1 Integer Types:
“The bigint type is designed to be used when the range of the integer type is insufficient.”
The bigint input function parses the text as a base-10 integer. Anything that isn’t a clean integer (commas, decimals, letters, blank) cannot be parsed and is rejected with 22P02.
Common causes
- Thousands separators or currency symbols in the value.
- An empty string passed instead of NULL.
- A decimal value where an integer is required.
How to fix it
- Strip separators/symbols and pass a clean integer.
- Use NULL (not
'') for missing values. - Round/cast decimals appropriately before insert (e.g.
round(x)::bigint).
Related & next steps
Reference: PostgreSQL 18 Section 8.1 “Numeric Types”.
Thanks — noted. This helps keep the database accurate.