A package is a database object that groups logically related PL/SQL types, items, functions and procedures. Packages usually have two parts, a specification and a body. The specification is the interface to your application. The body implements the specification.
Topics:
See Also: SQL*Plus User's Guide and Reference for information about PL/SQL packages |
To create a package:
Navigate to Object Browser:
Click the SQL Workshop icon on the Workspace home page.
Click Object Browser.
Object Browser appears.
Click Create.
From the list of object types, select Package.
Select the type of package you want to create:
Specification
Body
Package with methods on database tables
If you select Specification:
Enter a name and click Next.
The wizard creates a dummy package specification and displays it for editing.
Edit the specification and click Finish.
If you select Body:
Select the package you want to create the body for and click Next
The wizard creates a package body with stubbed out calls identified in the specification and displays it for editing.
Edit the package body and click Finish.
If you select Package with methods on database tables:
Enter a name and click Next.
Select up to ten tables and click Next.
The wizard creates a specification and body with insert, update, delete, and GET APIs for the selected tables. Note that you have the option to show or download the specification or body.
Click Finish.
When you access a package in Object Browser the specification appears.
To view a specification:
Navigate to Object Browser:
Click the SQL Workshop icon on the Workspace home page.
Click Object Browser.
Object Browser appears.
From the Object list, select Packages.
From the Object Selection pane, select a package.
The Specification appears. You can copy the code in this view for use in other tools.
Click the tabs at the top of the page to view different reports about the package. Table 18-7 describes all available views.
Table 18-7 Available Views for Packages
View | Description |
---|---|
Specification |
(Default) Displays the package specification. This define the interface to your application. Actions you can perform include:
|
Body |
Displays the package body, if one exists, for the selected package. Actions you can perform include:
|
Dependencies |
Displays objects that use (or depend on) on the current package and objects the package depends on. |
Errors |
Displays errors related to the current package. |
Grants |
Lists details of grants for the current package, including privilege, grantee, grantable, grantor, and object name. |
When you edit a package, you can edit the code manually, perform a search and replace, and compile the package.
To edit a package manually:
Navigate to Object Browser:
Click the SQL Workshop icon on the Workspace home page.
Click Object Browser.
Object Browser appears.
From the Object list, select Packages.
From the Object Selection pane, select a package.
The Specification appears. You can copy the code in this view for use in other tools. Note you can edit both the specification and the body fromObject Browser.
Click Edit to activate edit mode.
Click Find to perform a basic search and replace.
Note: You can expand the Edit pane by clicking the Full Screen icon in the upper right of the pane, beneath the Create button. |
If you edit and make changes to a package, you need to compile in order to save your changes. There is no save function because this is just a view of the object within the database.
Click Compile to compile the current package. Compiling re-creates the object in the database. If the compile fails, an error message display above the code.