CREATE OR REPLACE PACKAGE my_pkg_overload
AS
PROCEDURE p;
END my_pkg_overload;
CREATE OR REPLACE PACKAGE BODY my_pkg_overload AS
PROCEDURE p IS
l_data NUMBER;
l_other_data NUMBER;
PROCEDURE p_inner(p_data IN OUT NUMBER) IS
BEGIN
l_data := l_data + 1;
p_data := p_data / 2;
END;
PROCEDURE p_inner(p_input IN NUMBER, p_data IN OUT NUMBER) IS
BEGIN
p_data := p_input + l_data +
p_data;
END;
FUNCTION p_inner(p_data IN NUMBER) RETURN NUMBER IS
functionresult NUMBER;
BEGIN
functionresult := p_data + 1;
RETURN(functionresult);
END;
BEGIN
l_data := 42;
l_other_data := 84;
p_inner(l_other_data);
dbms_output.put_line('l_data = ' ||
l_data || ', l_other_data = ' ||
l_other_data);
l_other_data :=
p_inner(l_other_data);
dbms_output.put_line('l_data = ' ||
l_data || ', l_other_data = ' ||
l_other_data);
p_inner(l_data, l_other_data);
dbms_output.put_line('l_data = ' ||
l_data || ', l_other_data = ' ||
l_other_data);
END;
END my_pkg_overload;
Output
----------------------------------------
l_data = 43, l_other_data = 42
l_data = 43, l_other_data = 43
l_data = 43, l_other_data = 129
----------------------------------------
l_data = 43, l_other_data = 42
l_data = 43, l_other_data = 43
l_data = 43, l_other_data = 129
No comments:
Post a Comment