Managing Packages

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:

Creating a Package

To create a package:

  1. On the Workspace home page, click SQL Workshop and then Object Browser.

    Object Browser appears.

  2. Click Create.

  3. From the list of object types, select Package.

  4. Select the type of package you want to create, then click Next:

    • Specification

    • Body

    • Package with methods on database tables

  5. If you select Specification:

    1. Enter a name and click Next.

      The wizard creates a dummy package specification and displays it for editing.

    2. Edit the specification and click Finish.

  6. If you select Body:

    1. 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.

    2. Edit the package body and click Finish.

  7. If you select Package with methods on database tables:

    1. Enter a name and click Next.

    2. 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.

    3. To confirm, click Finish.

Viewing a Package

When you access a package in Object Browser the specification appears.

To view a specification:

  1. On the Workspace home page, click SQL Workshop and then Object Browser.

    Object Browser appears.

  2. From the Object list, select Packages.

  3. From the Object Selection pane, select a package.

    The Specification appears. You can also edit the code in this view.

Summary of Available Views

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

View Description

Specification

Displays the package specification. This defines the interface to your application. Actions you can perform include:

  • Edit the code manually

  • Save & Compile

  • Find & Replace

  • Undo

  • Redo

  • Download Source

  • Drop

Body

Displays the package body, if one exists, for the selected package. Actions you can perform include:

  • Edit the code manually

  • Save & Compile

  • Find & Replace

  • Undo

  • Redo

  • Download Source

  • Drop

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.


Editing a Package

When you edit a package, you can edit the code manually, perform a search and replace, and compile the package.

Editing a Package Manually

To edit a package manually:

  1. On the Workspace home page, click SQL Workshop and then Object Browser.

    Object Browser appears.

  2. From the Object list, select Packages.

  3. From the Object Selection pane, select a package.

    The Specification appears. You can edit the code in this view.

  4. Click Find & Replace to perform a basic search and replace.

Compiling a Package

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:

  1. On the Workspace home page, click SQL Workshop and then Object Browser.

    Object Browser appears.

  2. From the Object list, select Packages.

  3. From the Object Selection pane, select a package.

    The Specification appears.

  4. 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.

Downloading a Package

To download a package:

  1. On the Workspace home page, click SQL Workshop and then Object Browser.

    Object Browser appears.

  2. From the Object list, select Packages.

  3. From the Object Selection pane, select a package.

    The Specification appears.

  4. Click Download Source to save the current package as a file.

Dropping a Package

To drop a package while viewing the Specification:

  1. On the Workspace home page, click SQL Workshop and then Object Browser.

    Object Browser appears.

  2. From the Object list, select Packages.

  3. From the Object Selection pane, select a package.

    The Specification appears.

  4. Click Drop.

  5. To confirm, click Finish.

To drop a package while viewing the Body:

  1. On the Workspace home page, click SQL Workshop and then Object Browser.

    Object Browser appears.

  2. From the Object list, select Packages.

  3. From the Object Selection pane, select a package.

    The Specification appears.

  4. Click the Body tab.

  5. Click Drop.

  6. To confirm, click Finish.