PostgreSQL error code
PostgreSQL error 2202G
2202G is the SQLSTATE PostgreSQL reports for invalid tablesample repeat, in class 22, Data Exception.
| SQLSTATE | 2202G |
|---|---|
| Condition name | invalid_tablesample_repeat |
| Class | 22 — Data Exception |
Reproduce it, then fix it
REPEATABLE takes the seed that makes the sample the same on every run, and the seed can’t be NULL. Any number works. Run the broken query to see the error, then switch to the fixed one. Edit either freely; every run is rolled back.
SELECT name FROM products TABLESAMPLE SYSTEM (50) REPEATABLE (NULL);
SELECT name FROM products TABLESAMPLE SYSTEM (50) REPEATABLE (42);