如何在Oracle PL/SQL类型中定义无参数构造函数?我试过这个:
create or replace type FooBar as object
(
constructor function FooBar() return self as result
);
...
foo_bar := FooBar();
Run Code Online (Sandbox Code Playgroud)
但是类型声明中的空参数列表会引发PLS-00103.
在无参数函数的名称后面不需要括号,你需要一个构造函数体的定义:
create or replace type FooBar as object
(
bar NUMBER(1,0)
,constructor function FooBar return self as result
);
/
create or replace type body FooBar is
constructor function FooBar return self as result
IS
BEGIN
RETURN;
END;
end;
/
declare
foo foobar;
begin
foo := foobar();
end;
/
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3388 次 |
| 最近记录: |