我有包裹:
create or replace PACKAGE overload_pkg IS
PROCEDURE what_am_i (p_x IN VARCHAR2);
PROCEDURE what_am_i (p_x IN NUMBER);
PROCEDURE what_am_i (p_x IN DATE);
END overload_pkg;
与身体:
create or replace PACKAGE BODY overload_pkg IS
PROCEDURE what_am_i (p_x IN VARCHAR2) IS
BEGIN
pri('Here I am, a VARCHAR2');
END what_am_i;
PROCEDURE what_am_i (p_x IN NUMBER) IS
BEGIN
pri('Here I am, a NUMBER');
END what_am_i;
PROCEDURE what_am_i (p_x IN DATE) IS
BEGIN
pri('Here I am, a DATE');
END what_am_i;
END overload_pkg;
然而,当我调用包程序时:
BEGIN
overload_pkg.what_am_i('varchar2');
overload_pkg.what_am_i(1234);
overload_pkg.what_am_i('2018-04-06');
END;
,或我能想到的任何其他日期格式,Oracle 认为它是 VARCHAR 或 NUMBER。输出:
我在这里,一个 VARCHAR2
我在这里,一个数字
我在这里,一个 VARCHAR2
已处理报表。
唯一有效的是...
BEGIN
overload_pkg.what_am_i('varchar2');
overload_pkg.what_am_i(1234);
overload_pkg.what_am_i(to_DATE('08-APR-2018', 'DD-MON-YYYY'));
END;
但我认为 Oracle 可以识别日期,因为它会进行隐式转换。我很困惑。
提前致谢。