CREATE PROCEDURE statement
Related topics
CDL statements
ALTER-PROCEDURE-statement
The CREATE PROCEDURE statement defines a stored procedure.

CREATE PROCEDURE procedureOwner.procedureSchema.procedureName | This option specifies the fully qualified name of the new procedure. | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
VERSION versionNumber | This option specifies the version of the procedure. | ||||||||||||||
ORIGIN | This option specifies the origin of the procedure. The following table lists valid values for the ORIGIN keyword. ORIGIN keyword values
| ||||||||||||||
PARAMETERS (ordinality, parmUsage, parmName, dataType, subType, locator) | This option specifies the parameters for a procedure. Procedure parameter values
| ||||||||||||||
ACTIVE | This option indicates whether to activate the version of the procedure. ACTIVE keyword values
| ||||||||||||||
ADD_VERSION YES | This option specifies to create a new version of the procedure when you LIKE a native SQL stored procedure. | ||||||||||||||
APPLCOMPAT | This option indicates the package compatibility level for SQL. APPLCOMPAT keyword values
| ||||||||||||||
APPLICATION_ENCODING_SCHEME | This option specifies the encoding scheme for the procedure. APPLICATION_ENCODING_SCHEME keyword values
| ||||||||||||||
ARCHIVE SENSITIVE | This option specifies whether references to archive-enabled tables in SQL statements are affected by the value of the SYSIBMADM.GET_ARCHIVE global variable. ARCHIVE SENSITIVE keyword values
| ||||||||||||||
ASUTIME n | This option specifies the number of CPU service units for the procedure. A value of 0 indicates that no limit exists on the number of units. | ||||||||||||||
BUSINESS_TIME SENSITIVE | This option specifies whether references to application-period temporal tables in both static and dynamic SQL statements are affected by the value of the CURRENT TEMPORAL BUSINESS_TIME special register. BUSINESS_TIME SENSITIVE keyword values
| ||||||||||||||
COLLID | This option specifies the name of the package collection for the procedure. (The name of this collection is stored in the SYSIBM.SYSROUTINES table.) COLLID keyword values
| ||||||||||||||
COMMENT | This option specifies the comments for a procedure. COMMENT keyword values
| ||||||||||||||
COMMIT_ON_RETURN NO | This option specifies that Db2 should continue the unit of work. | ||||||||||||||
COMMIT_ON_RETURN YES | This option specifies that Db2 should commit the unit of work immediately. | ||||||||||||||
AUTONOMOUS | For native SQL procedures, this option specifies that Db2 should execute the SQL procedure in a unit of work that is independent from the calling application. | ||||||||||||||
CONCENTRATE | This option specifies whether to cache a dynamic SQL statement that specifies literal constants as a separate unique statement entry in the dynamic statement cache instead of sharing an existing statement in the cache CONCENTRATE keyword values
| ||||||||||||||
CONCURRENT_ACCESS_RESOLUTION | This option specifies the concurrent access resolution option to use for statements in a package. CONCURRENT_ACCESS_RESOLUTION keyword values
|

CURRENT_DATA | This option indicates whether to require data currency for cursors when the isolation level of cursor stability is in effect. CURRENT_DATA keyword values
| ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
DATE_FORMAT | This option specifies the format for the date for the procedure. DATE_FORMAT keyword values
| ||||||||||||||
DBINFO | This option indicates whether to pass the DBINFO structure to the stored procedure. DBINFO keyword values
| ||||||||||||||
DEBUG_MODE | This option specifies whether the procedure is allowed for debugging. DEBUG_MODE keyword values
| ||||||||||||||
DECIMAL | This option specifies the rules for a decimal operation (DEC31 or DEC15). DECIMAL keyword values
| ||||||||||||||
DEFER_PREPARE | This option indicates whether to immediately prepare dynamic SQL statements or to defer preparation. The following table lists valid values for the DEFER_PREPARE keyword. DEFER_PREPARE keyword values
| ||||||||||||||
DEGREE | This option specifies whether to attempt to run a query using parallel processing. DEGREE keyword values
| ||||||||||||||
DETERMINISTIC | This option indicates whether to use indeterminate or deterministic results for a procedure. DETERMINISTIC keyword values
| ||||||||||||||
DYNAMICRULES | This option specifies the values for the dynamic SQL attributes. DYNAMICRULES keyword values
| ||||||||||||||
EXPLAIN | This option indicates whether to add information about the package’s statements to the owner of the PLAN_TABLE table. EXPLAIN keyword values
| ||||||||||||||
EXTERNAL_NAME externalName JAVAExternalName | This option specifies the module that Db2 should load to execute the procedure. For parameters for a JAVAExternalName, see JAVAExternalName. | ||||||||||||||
IMMEDIATE_WRITE | This option indicates whether updates that are made to dependent page sets for group buffer pools should be immediately written. IMMEDIATE_WRITE keyword values
|

ISOLATION_LEVEL | This option specifies the isolation level. ISOLATION_LEVEL keyword values
| ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
KEEP_DYNAMIC | This option indicates whether dynamic SQL statements are purged at each commit point. KEEP_DYNAMIC keyword values
| ||||||||||||||||
LANGUAGE | This option specifies the implementation language of the procedure. LANGUAGE keyword values
| ||||||||||||||||
MAXIMUM_FAILURES | This option specifies the number of allowable failures for the procedure. MAXIMUM_FAILURES keyword values
| ||||||||||||||||
OPTHINT | This option specifies the value of the query optimization hint bind option. OPTHINT keyword values
| ||||||||||||||||
OWNER authorizationID | This option specifies the owner of the procedure. The OWNER parameter is included in the CDL statement only if the OVERRIDE( SPOWNER ) keyword is in the ALUIN input stream. | ||||||||||||||||
PACKAGE_OWNER | This option specifies the owner of the package. PACKAGE_OWNER keyword values
| ||||||||||||||||
PACKAGE_PATH | This option specifies the package path to use when the procedure executes. PACKAGE_PATH keyword values
| ||||||||||||||||
PARAMETER_CCSID | This option specifies the encoding scheme for the parameters for the procedure. PARAMETER_CCSID keyword values
| ||||||||||||||||
PARAMETER_STYLE | This option specifies the convention used to pass parameters to and return values from the procedure. PARAMETER_STYLE keyword values
| ||||||||||||||||
PARAMETER_VARCHAR | This option specifies the representation of variable length string parameters. PARAMETER_VARCHAR keyword values
| ||||||||||||||||
PROGRAM_TYPE | This option indicates whether the procedure runs as a main routine or a subroutine. PROGRAM_TYPE keyword values
|

QUALIFIER | This option specifies the implicit qualifier for the unqualified object names in the SQL statements. QUALIFIER keyword values
| ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
RELEASE_AT | This option specifies the release resources when the package was last bound or rebound. RELEASE_AT keyword values
| ||||||||||||||||||
RESULT_SETS value | This option specifies the number of query result sets that the procedure can return. Valid values are 0 through 32767. | ||||||||||||||||||
REOPT | This option specifies whether to have Db2 determine an access path at runtime. REOPT keyword values
| ||||||||||||||||||
ROUNDING | This option specifies the rounding mode when the package is bound. The following table lists valid values for the ROUNDING keyword. ROUNDING keyword values
| ||||||||||||||||||
RUN_OPTIONS | This option specifies the language environment runtime options for the procedure. RUN_OPTIONS keyword values
| ||||||||||||||||||
SECURITY | If the procedure accesses resources that are protected by an external security product, this option specifies the authorization ID. SECURITY keyword values
| ||||||||||||||||||
SPECIAL_REGISTERS | This option specifies how special registers are set. SPECIAL_REGISTERS keyword values
| ||||||||||||||||||
SQL_DATA_ACCESS | This option specifies which SQL statements can be executed in the procedure. SQL_DATA_ACCESS keyword values
|

SQL_PATH | This option specifies the SQL path that Db2 uses to resolve unqualified types and names in the procedure. SQL_PATH keyword values
| ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
STAY_RESIDENT | This option indicates whether the procedure load module remains resident in memory when the procedure ends. STAY_RESIDENT keyword values
| ||||||||||||||
SYSTEM_TIME SENSITIVE | This option indicates whether references to system-period temporal tables in both static and dynamic SQL statements are affected by the value of the CURRENT TEMPORAL SYSTEM_TIME special register. SYSTEM_TIME SENSITIVE keyword values
| ||||||||||||||
TIME_FORMAT | This option specifies the time format for values. TIME_FORMAT keyword values
| ||||||||||||||
FOR_UPDATE_CLAUSE | This option specifies whether the FOR UPDATE clause is required or optional for a DECLARE CURSOR statement. FOR_UPDATE_CLAUSE keyword values
| ||||||||||||||
VALIDATE | This option specifies whether to recheck errors. ALIDATE keyword values
| ||||||||||||||
WLM_ENVIRONMENT | This option specifies the workload manager (WLM) environment in which the procedure runs. The following table lists valid values for the WLM_ENVIRONMENT keyword. WLM_ENVIRONMENT keyword values
| ||||||||||||||
WLM_ENV_FOR_NESTED | For nested procedures, this option indicates which address space Db2 uses. WLM_ENV_FOR_NESTED keyword values
| ||||||||||||||
TEXT storedProcedureBody | This option specifies the statements in the body of the SQL procedure. |
JAVAExternalName
When the procedure is a JAVA procedure, JAVAExternalName uses the following parameters for an external name.

JAR_SCHEMA schema | This option specifies the schema of the JAR file. |
|---|---|
JAR_ID ID | This option specifies the name of the JAR file. |
EXTERNAL_NAME name | This option specifies the package.class.method that Db2 should load to execute the JAVA procedure. |
JAVASIGNATURE signature | This option specifies the signature of the JAR file. |