2F005
PostgreSQLERRORNotableSQL Routine ExceptionHIGH confidence
function executed in wrong section of rule
What this means
SQLSTATE 2F005 is raised when a function is called from a section of a rule where it is not permitted to execute — for example, calling a data-modifying function from the condition section of a rule.
Why it happens
- 1A rule condition or action contains a function call that is not allowed in that rule section
How to reproduce
Rule action calling a prohibited function.
expected output
ERROR: function executed in wrong section of rule
Fix
Move the function call to a permitted section of the rule or use triggers instead
WHEN When this error appears in a rule definition.
Why this works
Review the rule to ensure function calls are placed in appropriate sections. Consider using triggers (which have clearer execution semantics) instead of rules for complex logic.
Sources
Official documentation ↗
Class 2F — SQL Routine Exception
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev