38004
PostgreSQLERRORNotableExternal Routine ExceptionHIGH confidence
reading SQL data not permitted
What this means
SQLSTATE 38004 is raised when an external routine declared as NO SQL attempts to read data with a SELECT statement.
Why it happens
- 1An external function declared NO SQL executes a SELECT or other read statement
How to reproduce
NO SQL external function executing a SELECT.
expected output
ERROR: reading SQL-data not permitted
Fix
Change the function attribute to READS SQL DATA
WHEN When the function needs to read data.
Change the function attribute to READS SQL DATA
CREATE FUNCTION my_fn() RETURNS INT AS 'my_ext', 'my_fn' LANGUAGE C READS SQL DATA;
Why this works
READS SQL DATA permits SELECT statements in the function.
Sources
Official documentation ↗
Class 38 — External Routine Exception
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev