The ALTER PROCEDURE (SQL) statement alters a procedure at the current server.
This statement can be embedded in an application program or issued interactively. It is an executable statement that can be dynamically prepared.
The privileges held by the authorization ID of the statement must include at least one of the following:
If a distinct type is referenced in a parameter-declaration, the privileges held by the authorization ID of the statement must include at least one of the following:
For information on the system authorities corresponding to SQL privileges, see Corresponding System Authorities When Checking Privileges to a Function or Procedure and Corresponding System Authorities When Checking Privileges to a Distinct Type.
>>-ALTER--------------------------------------------------------> >--+-PROCEDURE--procedure-name--+--------------------------+-+--> | '-(--+----------------+--)-' | | '-parameter-type-' | '-SPECIFIC PROCEDURE--specific-name-----------------------' .-ALTER-. >--+-+-------+--option-list---------+-------------------------->< '-REPLACE--routine-specification-' routine-specification: |--+-------------------------------------+--+-------------+-----> '-(--+---------------------------+--)-' '-option-list-' | .-,---------------------. | | V | | '---parameter-declaration-+-' >--+----------------------+--SQL-routine-body-------------------| '-SET OPTION-statement-' parameter-declaration: .-IN----. |--+-------+--parameter-name--data-type-------------------------| +-OUT---+ '-INOUT-' parameter-type: |----data-type--+------------+----------------------------------| '-AS LOCATOR-' data-type: |--+-built-in-type------+---------------------------------------| '-distinct-type-name-' option-list: .-NOT DETERMINISTIC-. (1) .-MODIFIES SQL DATA-. |--+-------------------+-------+-------------------+------------> '-DETERMINISTIC-----' +-READS SQL DATA----+ '-CONTAINS SQL------' .-CALLED ON NULL INPUT-. .-DYNAMIC RESULT SETS 0--------. >--+----------------------+--+------------------------------+---> '-DYNAMIC RESULT SETS--integer-' .-FENCED-----. >--+---------------------+--+------------+----------------------> +-ALLOW DEBUG MODE----+ '-NOT FENCED-' +-DISABLE DEBUG MODE--+ '-DISALLOW DEBUG MODE-' .-OLD SAVEPOINT LEVEL-. .-COMMIT ON RETURN NO--. >--+---------------------+--+----------------------+------------| '-NEW SAVEPOINT LEVEL-' '-COMMIT ON RETURN YES-'
SQL-routine-body: |--+-SQL-control-statement-----------------------+--------------| +-ALLOCATE DESCRIPTOR-statement---------------+ +-ALTER PROCEDURE (External)-statement--------+ +-ALTER SEQUENCE-statement--------------------+ +-ALTER TABLE-statement-----------------------+ +-COMMENT-statement---------------------------+ +-COMMIT-statement----------------------------+ +-CONNECT-statement---------------------------+ +-CREATE ALIAS-statement----------------------+ +-CREATE DISTINCT TYPE-statement--------------+ +-CREATE FUNCTION (External Scalar)-statement-+ +-CREATE FUNCTION (External Table)-statement--+ +-CREATE FUNCTION (Sourced)-statement---------+ +-CREATE INDEX-statement----------------------+ +-CREATE PROCEDURE (External)-statement-------+ +-CREATE SCHEMA-statement---------------------+ +-CREATE SEQUENCE-statement-------------------+ +-CREATE TABLE-statement----------------------+ +-CREATE VIEW-statement-----------------------+ +-DEALLOCATE DESCRIPTOR-statement-------------+ +-DECLARE GLOBAL TEMPORARY TABLE-statement----+ +-DELETE-statement----------------------------+ +-DESCRIBE-statement--------------------------+ +-DESCRIBE INPUT-statement--------------------+ +-DESCRIBE TABLE-statement--------------------+ +-DISCONNECT-statement------------------------+ +-DROP-statement------------------------------+ +-EXECUTE IMMEDIATE-statement-----------------+ +-GET DESCRIPTOR-statement--------------------+ +-GRANT-statement-----------------------------+ +-INSERT-statement----------------------------+ +-LABEL-statement-----------------------------+ +-LOCK TABLE-statement------------------------+ +-REFRESH TABLE-statement---------------------+ +-RELEASE-statement---------------------------+ +-RELEASE SAVEPOINT-statement-----------------+ +-RENAME-statement----------------------------+ +-REVOKE-statement----------------------------+ +-ROLLBACK-statement--------------------------+ +-SAVEPOINT-statement-------------------------+ +-SELECT INTO-statement-----------------------+ +-SET CONNECTION-statement--------------------+ +-SET CURRENT DEBUG MODE-statement------------+ +-SET CURRENT DEGREE-statement----------------+ +-SET DESCRIPTOR-statement--------------------+ +-SET ENCRYPTION PASSWORD-statement-----------+ +-SET PATH-statement--------------------------+ +-SET RESULT SETS-statement-------------------+ +-SET SCHEMA-statement------------------------+ +-SET TRANSACTION-statement-------------------+ +-UPDATE-statement----------------------------+ '-VALUES INTO-statement-----------------------'
built-in-type: |--+-+---SMALLINT---+--------------------------------------------------------------------------+--| | +-+-INTEGER-+--+ | | | '-INT-----' | | | '---BIGINT-----' | | .-(5,0)------------------------. | +-+-+-DECIMAL-+-+--+------------------------------+-----------------------------------------+ | | '-DEC-----' | | .-,0--------. | | | '-NUMERIC-----' '-(--integer--+-----------+--)-' | | '-, integer-' | | .-(--53--)------. | +-+-FLOAT--+---------------+-+--------------------------------------------------------------+ | | '-(--integer--)-' | | | +-REAL---------------------+ | | | .-PRECISION-. | | | '-DOUBLE--+-----------+----' | | .-(--1--)-------. | +-+-+-+-CHARACTER-+--+---------------+----------+--+----------------+---------------------+-+ | | | '-CHAR------' '-(--integer--)-' | +-FOR BIT DATA---+ | | | | '-+-+-CHARACTER-+--VARYING-+--(--integer--)-' +-FOR SBCS DATA--+ | | | | | '-CHAR------' | +-FOR MIXED DATA-+ | | | | '-VARCHAR----------------' '-ccsid-clause---' | | | | .-(--1M--)-------------. | | | '-----+-+-CHARACTER-+--LARGE OBJECT-+------+----------------------+--+----------------+-' | | | '-CHAR------' | '-(--integer--+---+--)-' +-FOR SBCS DATA--+ | | '-CLOB------------------------' +-K-+ +-FOR MIXED DATA-+ | | +-M-+ '-ccsid-clause---' | | '-G-' | | .-(--1--)-------. | +-+---GRAPHIC----+---------------+-------+--+--------------+--------------------------------+ | | '-(--integer--)-' | '-ccsid-clause-' | | +-+-GRAPHIC VARYING-+--(--integer--)---+ | | | '-VARGRAPHIC------' | | | | .-(--1M--)-------------. | | | '---DBCLOB----+----------------------+-' | | '-(--integer--+---+--)-' | | +-K-+ | | +-M-+ | | '-G-' | | .-(--1--)-------. | +-+-+-BINARY--+---------------+---------+-----------------+---------------------------------+ | | | '-(--integer--)-' | | | | | '-+-BINARY VARYING-+--(--integer--)-' | | | | '-VARBINARY------' | | | | .-(--1M--)-------------. | | | '---+-BLOB----------------+----+----------------------+-' | | '-BINARY LARGE OBJECT-' '-(--integer--+---+--)-' | | +-K-+ | | +-M-+ | | '-G-' | +-+-DATE-------------------+----------------------------------------------------------------+ | | .-(--0--)-. | | | +-TIME--+---------+------+ | | | .-(--6--)-. | | | '-TIMESTAMP--+---------+-' | | .-(--200--)-----. | +---DATALINK--+---------------+--+--------------+-------------------------------------------+ | '-(--integer--)-' '-ccsid-clause-' | '---ROWID-----------------------------------------------------------------------------------' ccsid-clause: .-NOT NORMALIZED-. |--CCSID--integer--+----------------+---------------------------| '-NORMALIZED-----'
The specified procedure is altered. The owner of the procedure and all privileges on the procedure are preserved.
If procedure-name() is specified, the procedure identified must have zero parameters.
If an unqualified distinct type name is specified, the database manager searches the SQL path to resolve the schema name for the distinct type.
For data types that have a length, precision, or scale attribute, use one of the following:
Specifying the FOR DATA clause or CCSID clause is optional. Omission of either clause indicates that the database manager ignores the attribute when determining whether the data types match. If either clause is specified, it must match the value that was implicitly or explicitly specified in the CREATE PROCEDURE statement.
The result sets are scrollable if a cursor is used to return a result set and the cursor is scrollable. If a cursor is used to return a result set, the result set starts with the current position. Thus, if 5 FETCH NEXT operations have been performed prior to returning from the procedure, the result set will start with the 6th row of the result set.
Result sets are only returned if both the following are true:
For more information about result sets see SET RESULT SETS.
If DEBUG MODE is not specified, but a DBGVIEW option in the SET OPTION statement is specified, the procedure cannot be debugged by the Unified Debugger, but can be debugged by the system debug facilities. If neither DEBUG MODE nor a DBGVIEW option is specified, the debug mode used is from the CURRENT DEBUG MODE special register.
The commit operation includes the work that is performed by the calling application process and the procedure.
If the procedure returns result sets, the cursors that are associated with must have been defined as WITH HOLD to be usable after the commit.
The maximum number of parameters allowed in an SQL procedure is 1024.
CONNECT, SET CONNECTION, RELEASE, DISCONNECT, and SET TRANSACTION statements are not allowed in a procedure that is running on a remote application server. COMMIT and ROLLBACK statements are not allowed in an ATOMIC SQL procedure or in a procedure that is running on a connection to a remote application server.
General considerations for defining or replacing procedures: See CREATE PROCEDURE for general information on defining a procedure. ALTER PROCEDURE (SQL) allows individual attributes or the routine specification to be altered while preserving the privileges on the procedure.
Alter Procedure Replace considerations: When an SQL procedure is replaced, SQL creates a temporary source file that will contain C source code with embedded SQL statements. A program object is then created using the CRTPGM command. The SQL options used to create the program are the options that are in effect at the time the ALTER PROCEDURE (SQL) statement is executed. The program is created with ACTGRP(*CALLER).
When an SQL procedure is altered, a new *PGM object is created and the procedure's attributes are stored in the created program object. If the *PGM object is saved and then restored to this or another system, the catalogs are automatically updated with those attributes.
The specific name is used as the name of the member in the source file and the name of the program object, if it is a valid system name. If the procedure name is not a valid system name, a unique name is generated. If a source file member with the same name already exists, the member is overlaid. If a module or a program with the same name already exists, the objects are not overlaid, and a unique name is generated. The unique names are generated according to the rules for generating system table names.
Syntax alternatives: The following keywords are synonyms supported for compatibility to prior releases. These keywords are non-standard and should not be used:
Modify the definition for an SQL procedure so that SQL changes are committed on return from the SQL procedure.
ALTER PROCEDURE UPDATE_SALARY_2 ALTER COMMIT ON RETURN YES