Error
Error Code: 38002

PostgreSQL Error 38002: Modifying SQL Data Not Permitted

📦 PostgreSQL
📋

Description

This error indicates that a function, procedure, or trigger attempted to modify SQL data (INSERT, UPDATE, DELETE, TRUNCATE) but was not permitted to do so. This typically occurs when the routine's volatility setting conflicts with its actions, or when security or transaction restrictions are in place.
💬

Error Message

modifying sql data not permitted
🔍

Known Causes

4 known causes
⚠️
Incorrect Function Volatility
A user-defined function declared as IMMUTABLE or STABLE attempts to execute DML operations (INSERT, UPDATE, DELETE). These functions are expected not to modify the database.
⚠️
Read-Only Transaction Context
The SQL statement containing the routine is executed within a transaction that has been explicitly set to READ ONLY. In such transactions, no data modification commands are permitted.
⚠️
Security Definer Function Restrictions
A SECURITY DEFINER function, despite running with elevated privileges, attempts an operation that is inherently restricted or disallowed by underlying security policies.
⚠️
Trigger Modification on Restricted Objects
A trigger function attempts to modify data on a view or specific table type where such modifications are not permitted by the system or underlying structure.
🛠️

Solutions

Coming Soon

Detailed step-by-step solutions for this error are being prepared. In the meantime, try these general troubleshooting tips:

General Troubleshooting Tips

  • Check the error message carefully for specific details
  • Review recent changes that might have caused the error
  • Search for the exact error code in the official documentation
  • Check log files for additional context
  • Try restarting the application or service
🔗

Related Errors

5 related errors