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:
"Using PL/SQL Packages" in Oracle Database PL/SQL Language Reference for additional information on PL/SQL packages.
"Using PL/SQL Subprograms" in Oracle Database PL/SQL Language Reference for information on PL/SQL subprograms
To create a package:
On the Workspace home page, click SQL Workshop and then Object Browser.
Object Browser appears.
Click Create.
From the list of object types, select Package.
Select the type of package you want to create, then click Next:
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.
To confirm, click Finish.
When you access a package in Object Browser the specification appears.
To view a specification:
On the Workspace home page, click SQL Workshop and then Object Browser.
Object Browser appears.
From the Object list, select Packages.
From the Object Selection pane, select a package.
The Specification appears. You can also edit the code in this view.
Click the tabs at the top of the page to view different reports about the package. Table 1-7 describes all available views.
Table 1-7 Available Views for Packages
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:
On the Workspace home page, click SQL Workshop and then Object Browser.
Object Browser appears.
From the Object list, select Packages.
From the Object Selection pane, select a package.
The Specification appears. You can edit the code in this view.
Click Find & Replace to perform a basic search and replace.
If you edit and make changes to a package, you must compile to save your changes. There is no save function because this is just a view of the object within the database.
To compile a package:
On the Workspace home page, click SQL Workshop and then Object Browser.
Object Browser appears.
From the Object list, select Packages.
From the Object Selection pane, select a package.
The Specification appears.
Click Save & Compile to compile the current package.
Compiling re-creates the object in the database. If the compilation fails, an error message displays above the code.
To download a package:
On the Workspace home page, click SQL Workshop and then Object Browser.
Object Browser appears.
From the Object list, select Packages.
From the Object Selection pane, select a package.
The Specification appears.
Click Download Source to save the current package as a file.
To drop a package while viewing the Specification:
On the Workspace home page, click SQL Workshop and then Object Browser.
Object Browser appears.
From the Object list, select Packages.
From the Object Selection pane, select a package.
The Specification appears.
Click Drop.
To confirm, click Finish.
To drop a package while viewing the Body:
On the Workspace home page, click SQL Workshop and then Object Browser.
Object Browser appears.
From the Object list, select Packages.
From the Object Selection pane, select a package.
The Specification appears.
Click the Body tab.
Click Drop.
To confirm, click Finish.