我创建了一个自己的类型,构造函数重载:
CREATE TYPE foo_type AS OBJECT(
foo_type INTEGER,
foo_number NUMBER(28, 28),
foo_varchar2 VARCHAR2(4000 CHAR),
CONSTRUCTOR FUNCTION foo_type (data NUMBER) RETURN SELF AS RESULT,
CONSTRUCTOR FUNCTION foo_type (data VARCHAR2) RETURN SELF AS RESULT
)
CREATE TYPE BODY foo_type AS
CONSTRUCTOR FUNCTION foo_type (data NUMBER) RETURN SELF AS RESULT
IS
BEGIN
foo_type := 1;
foo_number := data;
return;
END;
CONSTRUCTOR FUNCTION foo (data VARCHAR2) RETURN SELF AS RESULT
IS
BEGIN
foo_type := 2;
foo_varchar2 := data;
return;
END;
END;
虽然只要它有效,我就不会超载:
insert into test_table (field) values ( foo_type(1, 2.2, 'bar') )
但是当我编写构造函数时,它根本不起作用:
insert into test_table (field) values ( foo_type(2.2) )
或者
insert into test_table (field) values ( foo_type('bar') )
此时 oracle 说:“ORA-06553:太多声明 'foo_type' 匹配此调用”,因此:
insert into test_table (field) values ( foo_type(foo_varchar2 => 'bar') )
说:“ORA-009007:缺少右括号”。
我应该改变它的工作原理?
谢谢。