DBAtlas · Database operations atlas

2F003: prohibited_sql_statement_attempted

PostgreSQL

What does it mean?

A statement that is prohibited in that context was attempted inside an SQL function/routine. Belongs to Class 2F (sql_routine_exception). For example, a function expected to be read-only attempting to modify data.

Why does it happen?

Core PostgreSQL rarely raises this code; it usually comes from extension or procedural language code. Note: a function marked IMMUTABLE/STABLE that runs INSERT/UPDATE/DELETE does not raise 2F003; it raises '... is not allowed in a non-volatile function' with code 0A000 (feature_not_supported).

How to fix it

Read which statement was prohibited in the error message and check the documentation of the routine/extension involved. If you get the non-volatile function error (0A000), define the data-modifying function as VOLATILE (this is the default): CREATE FUNCTION ... LANGUAGE plpgsql VOLATILE. Remove data-modifying calls from places that must be read-only (index expressions, constraint checks).

Open in DBAtlas →

More from this engine