You are on page 1of 2

EX.NO.

5a PL/SQL - PROCEDURES

DATE:

AIM:

To implement and execute procedures in Oracle database using Procedural Language


concepts.

PROCEDURE:

STEP 1: Initialize the necessary parameters.

STEP 2: Develop the set of statements with the essential operational parameters.

STEP 3: Specify the Individual operation to be carried out.

STEP 4: Execute the procedure.

EX - 1: (In Parameter)

DECLARE
CREATE OR REPLACE PROCEDURE disp_ab (A INT, B INT) IS
BEGIN
DBMS_OUTPUT.PUT_LINE (’A + B = ’ || (A + B));
DBMS_OUTPUT.PUT_LINE (’A * B = ’ || (A * B));
END;

Which when ran, displays something like (depending on the values you provide)
CALL disp_ab (17,23);
A + B = 40
A * B = 391
*-*-*-*-*-*

EX - 2: (Out Parameter)
DECLARE
CREATE OR REPLACE PROCEDURE sum_ab (A INT, B INT, C OUT INT) IS
BEGIN
C := A + B;
END;
To run it, we also create a small code fragment:

DECLARE
R INT;
BEGIN
sum_ab(23,29,R);
DBMS_OUTPUT.PUT_LINE(’SUM IS: ’ || R);
END;
After running output will be: SUM IS: 52
*-*-*-*-*-*

EXAMPLE - 3: (IN Out Parameter)


DECLARE
CREATE OR REPLACE PROCEDURE doublen (N IN OUT INT) IS
BEGIN
N := N * 2;
END;
To run it, we also create a small code fragment:
DECLARE
R INT;
BEGIN
DBMS_OUTPUT.PUT_LINE(’BEFORE CALL R IS: ’ || R);
doublen(R);
DBMS_OUTPUT.PUT_LINE(’AFTER CALL R IS: ’ || R);
END;
After running output will be:
BEFORE CALL R IS: 7
AFTER CALL R IS: 14
*-*-*-*-*-*

RESULT:

Finally implement and execute procedures in Oracle database using Procedural Language
successfully.

You might also like