问题描述
我想调用一个重写的 PL/SQL 方法.举个例子:
I'd like to call an overridden PL/SQL method. Here's an example:
现在我想调用 proc
方法的继承版本.当我尝试执行像 treat(self as test).proc(s);
这样的显式转换时,它不会编译,因为 PLS-00363: expression 'SYS_TREAT' cannot be used as分配目标
Now I want to invoke the inherited version of the proc
method. When I try to do an explicit cast like treat(self as test).proc(s);
it won't compile because of PLS-00363: expression 'SYS_TREAT' cannot be used as an assignment target
类型主体在我使用局部变量时编译:
The type body compiles when I use a local variable:
但是当我像这样运行我的例子时
But when I run my example like this
...它抛出ORA-21780:超出对象持续时间的最大数量.
有什么方法可以调用 test::proc(无需序列化/反序列化)?
Is there any way to call test::proc (without serializing/deserializing)?
而且...在proc被调用后,如何在obj
中反映任何改变的属性(即n
)?
And... after proc has been called, how can any changed attributes (namely n
) be reflected in obj
?
更新(谢谢,tbone):
Update (Thanks, tbone):
我使用模板方法(之前"和之后")更改了我的方法的组织.每当我需要扩展方法时,我都会添加它们.
I changed the organization of my methods using template methods ('before' and 'after'). I add them whenever I need to extend a method.
推荐答案
要访问超级方法,请尝试通用调用或通用表达式.例如,使用个人超类型和学生子类型:
To access the super methods, try either general invocation or generalized expression. For example, using a person supertype and student subtype:
如果您使用的是 10g,则需要对函数进行一些不同的组织,但与调用 super 方法的子函数具有相同的功能:
If you are on 10g, you'll need to organize the functions a bit different, but same functionality from the child to call the super method:
现在您可以从 student 中为 person 方法调用 show_super(),或者为 student 方法调用 show().
Now you'd call show_super() from student for the person method, or just show() for the student method.
来自文档,希望有所帮助.
From the docs, hope that helps.
这篇关于如何调用 Oracle PL/SQL 对象超级方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!