Your browser does not support JavaScript. This help page requires JavaScript to render correctly. Tutorial: Declaring Variables and Constants in a Subprogram
Skip Headers
Previous
Previous
 
Next
Next

Tutorial: Declaring Variables and Constants in a Subprogram

This tutorial shows how to use the SQL Developer tool Edit to declare variables and constants in the EMP_EVAL.calculate_score function (specified in "Tutorial: Creating a Package Specification"). (This tutorial is also an example of changing a package body.)

To declare variables and constants in calculate_score function:

  1. On the Connections tab, expand the hr_conn information by clicking the plus sign (+) to the left of the hr_conn icon.

    Under the hr_conn icon, a list of schema object types appears.

  2. Expand Packages.

    A list of packages appears.

  3. Expand EMP_EVAL.

    A list appears.

  4. Right-click EMP_EVAL Body.

    A list of choices appears.

  5. Click Edit.

    The EMP_EVAL Body pane appears, showing the code for the package body.

  6. Between RETURN NUMBER AS and BEGIN, add these variable and constant declarations:

    n_score       NUMBER(1,0);                -- variable
    n_weight      NUMBER;                     -- variable
    max_score     CONSTANT NUMBER(1,0) := 9;  -- constant, initial value 9
    max_weight    CONSTANT NUMBER(8,8) := 1;  -- constant, initial value 1
    
  7. From the File menu, select Save.

    Oracle Database saves the changed package body.

Related Topics

Oracle Database PL/SQL Language Reference

Assigning Values to Variables with the Assignment Operator

Declaring and Assigning Values to Variables and Constants