background image
<< Entering the Function Code | Dropping Procedures and Functions >>
<< Entering the Function Code | Dropping Procedures and Functions >>

Modifying Procedures and Functions

Creating and Using Standalone Procedures and Functions
Developing and Using Stored Procedures 4-7
Modifying Procedures and Functions
You already created a new procedure and a new function. However, they both consist
of only the subprogram signature. In this section, you will edit a subprogram body.
To modify a function:
You will edit the function
calculate_score
to determine the weighted value of an
evaluation for a particular category.
1.
In the
calculate_score
pane, replace the body of the function with the
following code. The new code is in bold font.
BEGIN
RETURN
score * weight
;
END calculate_score;
2.
Compile and save the function; you may use the CTRL + S key combination.
Testing Procedures and Functions
Next, you will test the function that you just modified.
To test a function:
You will test the function
calculate_score
.
1.
In the Connections navigator hierarchy, right-click the
calculate_score
function. Select Run.
2.
In the Run PL/SQL window, click inside the PL/SQL Block pane, and edit the
assignments for the
score
and
weight
variables. The new code is in bold font.
v_Return := CALCULATE_SCORE(
CAT => CAT,
SCORE =>
8
,
WEIGHT =>
0.2
);
Click OK.
3.
In the Running - Log pane, note the following results:
Connecting to the database hr_conn.
v_Return = 1.6
Process exited.
See Also:
Oracle Database SQL Language Reference for information about the
ALTER PROCEDURE
statement
Oracle Database SQL Language Reference for information about the
ALTER FUNCTION
statement