Who Can Create a Package
The CREATE PACKAGE statement can be executed by:
-
Users with the
CREATE PACKAGEprivilege
The user who created the package header becomes its owner.
The CREATE PACKAGE statement can be executed by:
Users with the CREATE PACKAGE privilege
The user who created the package header becomes its owner.
CREATE PACKAGECreate a package header
CREATE 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
With DEFINER set for package pk, user US needs only the EXECUTE privilege on pk.If it were set for INVOKER, either the user or the package would also need the INSERT privilege on table t.
create table t (i integer);
set term ^;
create package pk SQL SECURITY DEFINER
as
begin
function f(i integer) returns int;
end^
create package body pk
as
begin
function f(i integer) returns int
as
begin
insert into t values (:i);
return i + 1;
end
end^
set term ;^
grant execute on package pk to user us;
commit;
connect 'localhost:/tmp/69.fdb' user us password 'pas';
select pk.f(3) from rdb$database;
ALTER PACKAGEAlters a package header
DSQL
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.
The ALTER PACKAGE statement can be executed by:
The owner of the package
Users with the ALTER ANY PACKAGE privilege
ALTER PACKAGEALTER 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 PACKAGECreates a package header if it does not exist, or alters a package header
DSQL
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.
CREATE OR ALTER PACKAGECREATE OR 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
DROP PACKAGEDrops a package header
DSQL
DROP PACKAGE package_name
| Parameter | Description |
|---|---|
package_name |
Package name |
The DROP PACKAGE statement deletes an existing package header.If a package body exists, it will be dropped together with the package header.If there are still dependencies on the package, an error will be raised.
The DROP PACKAGE statement can be executed by:
The owner of the package
Users with the DROP ANY PACKAGE privilege
DROP PACKAGEDROP PACKAGE APP_VAR
RECREATE PACKAGEDrops a package header if it exists, and creates a package header
DSQL
RECREATE PACKAGE package_name
[SQL SECURITY {INVOKER | DEFINER}]
AS
BEGIN
[ <package_item> ... ]
END
!! See syntax of CREATE PACKAGE for further rules!!
The RECREATE PACKAGE statement creates a new package or recreates an existing package header.If a package header with the same name already exists, then this statement will first drop it and then create a new package header.It is not possible to recreate the package header if there are still dependencies on the existing package, or if the body of the package exists.Existing privileges of the package itself are not preserved, nor are privileges to execute the procedures or functions of the package.
RECREATE PACKAGERECREATE 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