FirebirdSQL logo

ALTER PACKAGE

Alters a package header

Available in

DSQL

Syntax
ALTER PACKAGE package_name
[SQL SECURITY {INVOKER | DEFINER}]
AS
BEGIN
  [ <package_item> ... ]
END

!! See syntax of CREATE PACKAGE for further rules!!

The ALTER PACKAGE statement modifies the package header.It can be used to change the number and definition of procedures and functions, including their input and output parameters.However, the source and compiled form of the package body is retained, though the body might be incompatible after the change to the package header.The validity of a package body for the defined header is stored in the column RDB$PACKAGES.RDB$VALID_BODY_FLAG.

Altering a package without specifying the SQL SECURITY clause will remove the SQL Security property if currently set for this package.This means the behaviour will revert to the database default.

Who Can Alter a Package

The ALTER PACKAGE statement can be executed by:

  • Administrators

  • The owner of the package

  • Users with the ALTER ANY PACKAGE privilege

Examples of ALTER PACKAGE

Modifying a package header
ALTER PACKAGE APP_VAR
AS
BEGIN
  FUNCTION GET_DATEBEGIN() RETURNS DATE DETERMINISTIC;
  FUNCTION GET_DATEEND() RETURNS DATE DETERMINISTIC;
  PROCEDURE SET_DATERANGE(ADATEBEGIN DATE,
      ADATEEND DATE DEFAULT CURRENT_DATE);
END

CREATE OR ALTER PACKAGE

Creates a package header if it does not exist, or alters a package header

Available in

DSQL

Syntax
CREATE OR ALTER PACKAGE package_name
[SQL SECURITY {INVOKER | DEFINER}]
AS
BEGIN
  [ <package_item> ... ]
END

!! See syntax of CREATE PACKAGE for further rules!!

The CREATE OR ALTER PACKAGE statement creates a new package or modifies an existing package header.If the package header does not exist, it will be created using CREATE PACKAGE.If it already exists, then it will be modified using ALTER PACKAGE while retaining existing privileges and dependencies.