PostgreSQL 17.12Lab-verified · 2026-11-30

PostgreSQL 08P01: bind message supplies 1 parameters, but prepared statement "" requires 0

The number of values sent does not match the number of $n placeholders in the SQL.

PostgreSQL 17.12
08P01: bind message supplies 1 parameters, but prepared statement "" requires 0

Jump to a cause

  1. 01$1 written inside quotes, e.g. LIKE '%$1%'
  2. 02Fewer values than placeholders ($1, $2 but one value)

Lab-verifiedReproduced and fixed on PostgreSQL 17.12 · 2026-11-30 · container image postgres:17

When an application runs a parameterized query, the driver sends the SQL with $1, $2... and then a Bind message with the values. If the counts differ, PostgreSQL rejects the Bind with 08P01. prepared statement "" is the unnamed statement drivers use for one-off queries.

We reproduced it on PostgreSQL 17 with psql's \bind, which sends parameters the same way a driver does: a $1 inside a string literal, and two placeholders with one value.

01$1 written inside quotes, e.g. LIKE '%$1%'

Inside '%$1%' the $1 is just text, so the statement has 0 parameters. The application sent 1 value (KIM), hence supplies 1 parameters, but ... requires 0.

Setup
Setuprun as lab_a
CREATE TABLE customers (id int PRIMARY KEY, name text);
INSERT INTO customers VALUES (1, 'KIM MINA'), (2, 'LEE JUN'), (3, 'PARK KIM');
OUTPUT
CREATE TABLE
INSERT 0 3
Reproducerun as lab_a
SELECT id, name FROM customers WHERE name LIKE '%$1%' \bind KIM \g
✕ ERROR
ERROR:  08P01: bind message supplies 1 parameters, but prepared statement "" requires 0
Checkrun as lab_a
SELECT id, name FROM customers WHERE name LIKE '%$1%';
OUTPUT
 id | name
----+------
(0 rows)

Run without parameters, LIKE '%$1%' returned 0 rows: it searched for the literal text $1. Build the pattern outside the quotes: LIKE '%' || $1 || '%'. With the same value KIM it returned 2 rows (KIM MINA, PARK KIM).

After the fixrun as lab_a
SELECT id, name FROM customers WHERE name LIKE '%' || $1 || '%' \bind KIM \g
✓ SUCCESS
 id |   name
----+----------
  1 | KIM MINA
  3 | PARK KIM
(2 rows)

02Fewer values than placeholders ($1, $2 but one value)

The INSERT has $1 and $2, but only 10 was sent. The message shows both counts: supplies 1 parameters, but ... requires 2.

Setup
Setuprun as lab_a
CREATE TABLE orders (id serial PRIMARY KEY, customer_id int, amount numeric(10,2));
OUTPUT
CREATE TABLE
Reproducerun as lab_a
INSERT INTO orders (customer_id, amount) VALUES ($1, $2) \bind 10 \g
✕ ERROR
ERROR:  08P01: bind message supplies 1 parameters, but prepared statement "" requires 2
Checkrun as lab_a
SELECT column_name, data_type FROM information_schema.columns
WHERE table_name = 'orders' ORDER BY ordinal_position;
OUTPUT
 column_name | data_type
-------------+-----------
 id          | integer
 customer_id | integer
 amount      | numeric
(3 rows)

orders has id, customer_id and amount; id is serial, so the INSERT needs two values. Sending both values (10, 15000) inserted the row, and the SELECT showed customer_id 10 and amount 15000.00.

After the fixrun as lab_a
INSERT INTO orders (customer_id, amount) VALUES ($1, $2) \bind 10 15000 \g
SELECT * FROM orders;
✓ SUCCESS
INSERT 0 1
 id | customer_id |  amount
----+-------------+----------
  1 |          10 | 15000.00
(1 row)

FAQ

Why does LIKE '%$1%' not work in PostgreSQL?

A placeholder inside quotes is part of the string, not a parameter. Our query then required 0 parameters and failed with 08P01. LIKE '%' || $1 || '%' worked.

What is prepared statement "" in the error?

It is the unnamed prepared statement used for a single parameterized query. In our psql \bind test, both errors showed prepared statement "".

How do I find which query has the wrong parameter count?

Compare the numbers in the message with the highest $n in the SQL. "supplies 1 ... requires 0" usually means a $1 is hidden inside quotes; "requires 2" with 1 supplied means a value is missing.

How we verify

Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.

lab_a and lab_b are ordinary roles created for the test, each owning a schema of the same name; postgres is the superuser. PostgreSQL 17.12