A user of mine just raised a strange issue... While it is possible to use a parameter in a LIMIT clause, PostgreSQL does not seem to allow using one in a FETCH NEXT clause. In other words, while the following works:
SELECT 1 LIMIT $1; The following generates a syntax error: SELECT 1 FETCH NEXT $1 ROWS ONLY; Since LIMIT and FETCH NEXT are supposed to be equivalent this behavior is odd. More generally, is there some documentation on where exactly PostgreSQL allows parameters and where it doesn't? I occasionally get complaints from users expecting parameters to work in DDL, or even in table/column names in SELECT queries... I haven't seen a resource like this.