2202H
PostgreSQLERRORNotableData ExceptionHIGH confidence
invalid tablesample argument
What this means
SQLSTATE 2202H is raised when a TABLESAMPLE clause receives an invalid argument — for example, a sampling percentage outside the range 0–100 for BERNOULLI or SYSTEM sampling.
Why it happens
- 1Using a sampling percentage less than 0 or greater than 100 in TABLESAMPLE BERNOULLI or TABLESAMPLE SYSTEM
How to reproduce
TABLESAMPLE with an invalid percentage.
trigger — this will error
trigger — this will error
SELECT * FROM large_table TABLESAMPLE BERNOULLI(150);
expected output
ERROR: sample percentage must be between 0 and 100
Fix
Use a sampling percentage between 0 and 100
WHEN When using TABLESAMPLE for random sampling.
Use a sampling percentage between 0 and 100
SELECT * FROM large_table TABLESAMPLE BERNOULLI(10); -- 10% sample
Why this works
The BERNOULLI and SYSTEM methods require a percentage in [0, 100]. Values outside this range cause 2202H.
Version notes
Postgres 9.5+
TABLESAMPLE syntax introduced in 9.5.
Sources
Official documentation ↗
Class 22 — Data Exception
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev