Creates a package specification.
Syntax
CREATE [ OR REPLACE ] PACKAGE name
[ AUTHID { DEFINER | CURRENT_USER } ]
{ IS | AS }
[ declaration; ] [, ...]
[ { PROCEDURE proc_name
[ (argname [ IN | IN OUT | OUT ] argtype [ DEFAULT value ]
[, ...]) ];
[ PRAGMA RESTRICT_REFERENCES(name,
{ RNDS | RNPS | TRUST | WNDS | WNPS } [, ... ] ); ]
|
FUNCTION func_name
[ (argname [ IN | IN OUT | OUT ] argtype [ DEFAULT value ]
[, ...]) ]
RETURN rettype [ DETERMINISTIC ];
[ PRAGMA RESTRICT_REFERENCES(name,
{ RNDS | RNPS | TRUST | WNDS | WNPS } [, ... ] ); ]
}
] [, ...]
END [ name ]
Description
CREATE PACKAGE creates a package specification. CREATE OR REPLACE TRIGGER either creates a new package specification or replaces an existing specification.
If you specify a schema name, the package is created in the specified schema. Otherwise, the package is created in the current schema. The name of the new package cannot be the same as an existing package in the same schema. If you want to update the definition of an existing package, you can use the CREATE OR REPLACE PACKAGE command.
The user that creates the stored procedure is the owner of the package.
Parameters
Parameter | Description |
---|---|
name | The name of the package to be created. The name can be schema-qualified. |
DEFINER | CURRENT_USER | The privileges that determine whether access is allowed to database objects referenced in the package. DEFINER indicates the privileges of the package owner. CURRENT_USER indicates the privileges of the current user executing a program in the package. The default value is DEFINER. |
declaration | A public variable, type, cursor, or REF CURSOR declaration. |
proc_name | The name of a public stored procedure. |
argname | The name of an argument. |
IN | IN OUT | OUT | The argument mode. |
argtype | The data types of the program arguments. |
DEFAULT value | The default value of an input argument. |
func_name | The name of a public function. |
rettype | The return data type. |
DETERMINISTIC | DETERMINISTIC is a synonym for IMMUTABLE. A DETERMINISTIC stored procedure cannot modify the database and always returns the same result if the same argument value is specified. The stored procedure does not perform database lookups or use information that is excluded from the argument list. If this clause is included, a call to the stored procedure with all-constant arguments is immediately replaced with the stored procedure value. |
RNDS | RNPS | TRUST | WNDS | WNPS | The keywords are accepted for compatibility and are ignored. |
Examples
The package specification (empinfo) contains three public components: a public variable, a public stored procedure, and a public function.
CREATE OR REPLACE PACKAGE empinfo
IS
emp_name VARCHAR2(10);
PROCEDURE get_name (
p_empno NUMBER
);
FUNCTION display_counter
RETURN INTEGER;
END;