2F003
PostgreSQLERRORNotableSQL Routine ExceptionHIGH confidence

prohibited SQL statement attempted

What this means

SQLSTATE 2F003 is raised when a SQL function attempts to execute a statement type that is prohibited by its declared data access category — for example, a NO SQL function containing any SQL statement.

Why it happens
  1. 1A SQL function declared NO SQL contains a SQL statement
  2. 2A SQL function executes a statement type not allowed by its data access declaration
How to reproduce

NO SQL function containing a SQL statement.

expected output

ERROR:  prohibited statement attempted in SQL function

Fix

Match the function data access attribute to the actual statements used

WHEN When function data access attributes and content are mismatched.

Why this works

Use CONTAINS SQL for functions with SQL statements, READS SQL DATA for read-only SQL, MODIFIES SQL DATA for write SQL. NO SQL means the function has no SQL statements at all.

Sources
Official documentation ↗

Class 2F — SQL Routine Exception

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All PostgreSQL errors