Who Can Alter a Procedure
The ALTER PROCEDURE
statement can be executed by:
-
The owner of the stored procedure
-
Users with the
ALTER ANY PROCEDURE
privilege
The ALTER PROCEDURE
statement can be executed by:
The owner of the stored procedure
Users with the ALTER ANY PROCEDURE
privilege
ALTER PROCEDURE
ExampleGET_EMP_PROJ
stored procedure.ALTER PROCEDURE GET_EMP_PROJ (
EMP_NO SMALLINT)
RETURNS (
PROJ_ID VARCHAR(20))
AS
BEGIN
FOR SELECT
PROJ_ID
FROM
EMPLOYEE_PROJECT
WHERE
EMP_NO = :emp_no
INTO :proj_id
DO
SUSPEND;
END
CREATE OR ALTER PROCEDURE
Creates a stored procedure if it does not exist, or alters a stored procedure
DSQL
CREATE OR ALTER PROCEDURE procname [ ( [ <in_params> ] ) ]
[RETURNS (<out_params>)]
{<psql_procedure> | <external-module-body>}
!! See syntax of CREATE PROCEDURE
for further rules !!
The CREATE OR ALTER PROCEDURE
statement creates a new stored procedure or alters an existing one.If the stored procedure does not exist, it will be created by invoking a CREATE PROCEDURE
statement transparently.If the procedure already exists, it will be altered and compiled without affecting its existing privileges and dependencies.
CREATE OR ALTER PROCEDURE
ExampleGET_EMP_PROJ
procedure.CREATE OR ALTER PROCEDURE GET_EMP_PROJ (
EMP_NO SMALLINT)
RETURNS (
PROJ_ID VARCHAR(20))
AS
BEGIN
FOR SELECT
PROJ_ID
FROM
EMPLOYEE_PROJECT
WHERE
EMP_NO = :emp_no
INTO :proj_id
DO
SUSPEND;
END
DROP PROCEDURE
Drops a stored procedure
DSQL, ESQL
DROP PROCEDURE procname
Parameter | Description |
---|---|
procname |
Name of an existing stored procedure |
The DROP PROCEDURE
statement deletes an existing stored procedure.If the stored procedure has any dependencies, the attempt to delete it will fail and raise an error.
The DROP PROCEDURE
statement can be executed by:
The owner of the stored procedure
Users with the DROP ANY PROCEDURE
privilege
DROP PROCEDURE
ExampleGET_EMP_PROJ
stored procedure.DROP PROCEDURE GET_EMP_PROJ;
RECREATE PROCEDURE
Drops a stored procedure if it exists, and creates a stored procedure
DSQL
RECREATE PROCEDURE procname [ ( [ <in_params> ] ) ]
[RETURNS (<out_params>)]
{<psql_procedure> | <external-module-body>}
!! See syntax of CREATE PROCEDURE
for further rules !!
The RECREATE PROCEDURE
statement creates a new stored procedure or recreates an existing one.If a procedure with this name already exists, the engine will try to drop it and create a new one.Recreating an existing procedure will fail at the COMMIT
request if the procedure has dependencies.
Warning
|
Be aware that dependency errors are not detected until the |
After a procedure is successfully recreated, privileges to execute the stored procedure, and the privileges of the stored procedure itself are dropped.
RECREATE PROCEDURE
ExampleGET_EMP_PROJ
stored procedure or recreating the existing GET_EMP_PROJ
stored procedure.RECREATE PROCEDURE GET_EMP_PROJ (
EMP_NO SMALLINT)
RETURNS (
PROJ_ID VARCHAR(20))
AS
BEGIN
FOR SELECT
PROJ_ID
FROM
EMPLOYEE_PROJECT
WHERE
EMP_NO = :emp_no
INTO :proj_id
DO
SUSPEND;
END