Common SQL Errors

PostgreSQL Error 22002: null_value_no_indicator_parameter Explained and Fixed

August 4, 2025

Error 22002 occurs when a NULL value is supplied without an indicator parameter in PostgreSQL embedded or parameterized SQL.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is the null_value_no_indicator_parameter error?

PostgreSQL Error 22002 (null_value_no_indicator_parameter) means the query tried to pass or fetch a NULL without providing an indicator variable. Add an indicator parameter, send the value as NULL using the binary protocol, or rewrite the query to avoid NULLs to resolve the issue.

Error Highlights

Typical Error Message

PostgreSQL Error 22002

Error Type

Data Error

Language

PostgreSQL

Symbol

null_value_no_indicator_parameter

Error Code

22002

SQL State

Explanation

Table of Contents

What is the null_value_no_indicator_parameter error?

Error 22002 signals that PostgreSQL received or returned a NULL value but did not get the required indicator parameter telling it the value is NULL.

The condition mostly appears in embedded SQL (ECPG), libpq binary-protocol calls, or when using server-side prepared statements from drivers like ODBC/JDBC.

What Causes This Error?

The driver sends a host variable’s data without marking it as NULL, so PostgreSQL cannot determine whether the value is NULL or just empty.

Using EXECUTE or FETCH in Embedded C without an accompanying indicator variable is the classic trigger.

How to Fix PostgreSQL Error 22002

Always pass a separate indicator parameter and set it to -1 to flag NULL.

In libpq, send a NULL pointer for the value and a length of 0.

Rewrite queries so that NOT NULL columns never receive NULL input.

Validate data before binding.

Common Scenarios and Solutions

ODBC Application - Bind SQL_NULL_DATA for the column to avoid the error.

ECPG Program - Add an int indicator variable after each nullable host variable.

Best Practices to Avoid This Error

Standardize data-access layers so every nullable column has a clear indicator path.

Use Galaxy collections to store tested parameterized queries so teammates reuse safe patterns.

Related Errors and Solutions

22004 (null_value_not_allowed) happens when a NULL hits a NOT NULL column; supply a real value instead.

22001 (string_data_right_truncation) occurs when data exceeds column size; trim or widen the column.

.

Common Causes

Related Errors

FAQs

Is Error 22002 a client or server problem?

Mostly client side. The server merely reports the missing indicator; fix your driver or embedded code.

Does this error affect psql interactive queries?

No. It surfaces in APIs that use host variables or binary protocols, not plain SQL entered in psql.

Can Galaxy detect missing indicator variables?

Galaxy’s AI copilot flags queries where nullable columns lack explicit NULL handling, reducing risk.

Will setting a default value solve Error 22002?

A default value avoids sending NULL altogether, which prevents the error, but only if the default is acceptable to your logic.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo