PL/SQL OVERLOADING PACKAGE

 


================ Package Specification =======================

Create or Replace Package OVERLOADING_PACKAGE

AS

   PROCEDURE DISPLAY_Result (p_lower IN NUMBER, p_upper IN NUMBER); 

   PROCEDURE DISPLAY_Result ( V1 IN NUMBER, V2 IN NUMBER, V3 IN NUMBER);

   PROCEDURE DISPLAY_Result ( V1 Varchar2, V2 Varchar2);

End;

/

================ Package body =======================

Create or Replace Package BODY OVERLOADING_PACKAGE

As

   Procedure DISPLAY_Result (p_lower IN NUMBER, p_upper IN NUMBER)

AS

Begin

   DBMS_OUTPUT.PUT_LINE('First Procedure');

FOR I IN P_lower.. p_upper

LOOP

   DBMS_OUTPUT.PUT_LINE(I);

End LOOP;

End;

   Procedure DISPLAY_Result ( V1 IN NUMBER, V2 IN NUMBER, V3 IN NUMBER)

AS

Begin

   DBMS_OUTPUT.PUT_LINE('Second Procedure');

   DBMS_OUTPUT.PUT_LINE(V1+V2+V3);

End;

   Procedure DISPLAY_Result ( V1 Varchar2, V2 Varchar2)

AS

Begin

   DBMS_OUTPUT.PUT_LINE('Third Procedure');

   DBMS_OUTPUT.PUT_LINE(V1 || V2);

End;

End;

============== Result =====================


SET SERVEROUTPUT ON


BEGIN

 OVERLOADING_PACKAGE.DISPLAY_Result (3,6);

 OVERLOADING_PACKAGE.DISPLAY_Result (5,6,8);

 OVERLOADING_PACKAGE.DISPLAY_Result ('GOOD','MORNING');

END;

/


First Procedure

3
4
5
6

Second Procedure

19

Third Procedure

GOOD MORNING



Post a Comment

Previous Post Next Post