Chapter 15 DBMS-Specific Features


Defining a package procedure

A package procedure is created in a database package and exists only in this package. If you delete the database package you also delete the procedures it contains.

A package procedure has the following properties:

Property Description
Name The name of the item which should be clear and meaningful, and should convey the item's purpose to non-technical users.
Code The technical name of the item used for generating code or scripts, which may be abbreviated, and should not generally include spaces.
Comment Additional information about the package procedure.
Stereotype Sub-classification used to extend the semantics of an object without changing its structure; it can be predefined or user-defined.
DB Package Name of the database package to which the procedure belongs.
Type Allows you to choose between procedure and function.
Return data type Allows you to define the return data type of a function.
Pragma Allows you to type a compiler directive, that is, a string for specifying compilation parameters for the procedure.
Public Allows you to declare the procedure in the package specification and to permit use from outside the database package.
A private procedure (check box deselected) is only defined in the package body.

Parameters

The Parameters tab lets you define the input and output values for procedures.

For example, in the CREDIT procedure, you have to define the following parameters:


Definition

The Definition tab lets you define package procedures. Package procedures are not built using the structure of templates defined in the DBMS. You have to type the entire package procedure definition. To do so, you can use operators and functions to insert script items into the cursor definition.

For example, the definition of the CREDIT package procedure is the following:

CREATE PROCEDURE credit (Account_number NUMBER, Amount IN NUMBER) AS
BEGIN
UPDATE accounts
SET balance = balance + amount
WHERE account_id = acc_no;
END;

 


Copyright (C) 2007. Sybase Inc. All rights reserved.