Parameter Mode (IN, OUT, IN OUT) in PLSQL
--====================================================
IN, OUT, IN OUT
Parameter Mode
--====================================================
CREATE OR REPLACE FUNCTION XX_EXPO_NUM_FUNC ( X IN NUMBER, Y IN NUMBER ) RETURN NUMBER AS
V_EXP_VALUE NUMBER:= 1;
BEGIN
FOR I IN 1..Y LOOP
V_EXP_VALUE :=
V_EXP_VALUE * X;
END LOOP;
RETURN V_EXP_VALUE;
END;
select XX_EXPO_NUM_FUNC ( 3 , 5 )
EXPO_VALUE from DUAL;
DECLARE
A NUMBER := 2;
B NUMBER := 5;
C NUMBER;
BEGIN
select XX_EXPO_NUM_FUNC (A , B )
EXPO_VALUE INTO
C from DUAL;
dbms_output.put_line ('Expo
Value is : ' || C);
END;
--====================================================
---CREATE OR
REPLACE FUNCTION XX_SUM_2_NUM_PROC ( X IN NUMBER, Y IN NUMBER ) RETURN NUMBER
AS
CREATE OR REPLACE PROCEDURE XX_SUM_2_NUM_PROC ( X IN NUMBER, Y IN NUMBER , Z OUT NUMBER) AS
V_EXP_VALUE NUMBER:= 1;
BEGIN
FOR I IN 1..Y LOOP
V_EXP_VALUE :=
V_EXP_VALUE * X;
END LOOP;
Z:= V_EXP_VALUE;
END;
DECLARE
A NUMBER := 2;
B NUMBER := 7;
C NUMBER;
BEGIN
XX_SUM_2_NUM_PROC (A, B, C);
dbms_output.put_line ('Expo
Value is : ' || C);
END;
--====================================================
CREATE OR REPLACE PROCEDURE XX_SUM_2_NUM_PROC_NEW ( X IN OUT NUMBER, Y IN OUT NUMBER ) AS
V_EXP_VALUE NUMBER:= 1;
BEGIN
FOR I IN 1..Y LOOP
V_EXP_VALUE :=
V_EXP_VALUE * X;
END LOOP;
Y:= V_EXP_VALUE;
END;
DECLARE
A NUMBER := 2;
B NUMBER := 9;
BEGIN
XX_SUM_2_NUM_PROC_NEW (A, B);
dbms_output.put_line ('Expo
Value is : ' || B);
END;
Comments
Post a Comment