Determining what SQL statements can be executed in routines
Many, but not all SQL statements can be executed in routines. Execution of a particular SQL statement within a routine is dependent on the type of routine, the implementation of the routine, the maximum SQL access level specified for the routine, and the privileges of the routine definer and invoker.
Before you begin
Determining what SQL statements can be executed within a routine before you implement your routine can ensure that you make the right choice of routine type and implementation from the start.
- The SQL access level of the routine must permit the execution
of the particular SQL statement.
- The SQL access level of a routine is specified in the CREATE statement for the routine.
- Some SQL access levels are not supported for certain types of routines. Refer to the following restrictions.
- The routine definer must have the necessary privileges to execute
the SQL statement.
- The privileges required to execute every supported SQL statement are provided in the SQL Reference.
- No other separate restriction restricts the execution of the statement.
- Refer to the SQL Reference for a list of restrictions specific to the given SQL statement.
Restrictions
- External functions cannot be specified with the MODIFIES SQL DATA access level.
- External procedures that will be called from a trigger cannot be specified with a MODIFIES SQL DATA access level.
Procedure
To determine what SQL statements can be invoked in a particular routine:
Results
If the SQL statement is indicated as being executable within a routine, the routine SQL access level meets the prerequisites for executing the statement within the routine, and all other prerequisites have been met, the SQL statement should be successfully executable from the routine.