Managing Packages

A package is a database object that groups logically related PL/SQL types, items, functions and procedures. You can create, view, edit, compile, drop, download a package, and view a report.

Packages usually have two parts, a specification and a body. The specification is the interface to your application. The body implements the specification.

See Also:

Creating a Package

Create a package using Object Browser. Select the type of package you want to create.

To create a package:

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

    Object Browser appears.

  2. Click the Create icon.
  3. From the list of object types, select Package.
  4. For Create Package, select the type of package you want to create:
    • Specification

    • Body

    • Package with methods on database table(s)

      Packages usually have two parts: Specification and Body.

  5. Click Next.
  6. If you select Specification:
    1. Package Name - Enter a package name. To preserve the case of the name you enter, click Preserve Case.

    2. Click Next.

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

    3. Edit the specification and click Create Package Specification.

  7. If you select Body:
    1. Package - 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 Create Package Body.

  8. If you select Package with methods on database tables:
    1. Package Name - Enter a package name. To preserve the case of the name you enter, click Preserve Case.

    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 Create Package.

Viewing a Package

Select a package from the Object Selection pane and view different reports about the 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.

  4. Click the tabs at the top of the page to view different reports about the package.

Reports for Packages

Alternative views available when viewing a package in Object Browser.

Table 2-7 describes all available reports for packages.

Table 2-7 Available Reports 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

  • Auto Complete

  • 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

  • Auto Complete

  • 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 Manually

Select a package from the Object Selection pane and click Find or Replace.

When you edit a package, you can edit the code manually, perform a search and replace, and compile the 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. You can edit the code in this view.

  4. To perform a basic search, click the Find icon (which resembles a magnifying glass).
  5. To replace existing code, click the Replace icon (which resembles a two-sided arrow).

Compiling a Package

If you edit and make changes to a view, 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

Select a package from the Object Selection pane and download a package by clicking Download Source to save the current package as a file.

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 While Viewing Specification

Select a package from the Object Selection pane and click Drop.

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.

Dropping a Package While Viewing the Body

Select a package from the Object Selection pane, click Body tab, and click Drop.

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.