Oracle 用户定义聚合函数的问题

发布于 2025-01-01 02:29:23 字数 1947 浏览 1 评论 0原文

我在聚合 udfs 上遇到了这个恼人的问题,它总是无法调用迭代方法。我的代码就像网络上的其他示例一样(包括 oracle docs 和 Asktom 上的示例)。我尝试更改 UDF 类型,但每次都会发生同样的情况。它说:

ORA-29925: cannot execute DBAODB.WMCONCATROUTINES.ODCIAGGREGATEITERATE
ORA-06553: PLS-306: wrong number or types of arguments in call to 'ODCIAGGREGATEITERATE'

Oracle 版本是 11.1.0.7.0,这是我的代码:

CREATE OR REPLACE TYPE WmConcatRoutines as object (
    tmpData number,

    STATIC FUNCTION ODCIAggregateInitialize( wmInst IN OUT WmConcatRoutines) RETURN number,
    MEMBER FUNCTION ODCIAggregateIterate(wmInst IN OUT WmConcatRoutines, value number) return number,
    MEMBER FUNCTION ODCIAggregateMerge(wmInst IN OUT WmConcatRoutines, wmInst2 IN WmConcatRoutines) return number,
    MEMBER FUNCTION ODCIAggregateTerminate(wmInst IN WmConcatRoutines, returnValue OUT number, flags IN number) return number
);
/

CREATE OR REPLACE TYPE BODY WmConcatRoutines IS 
    STATIC FUNCTION ODCIAggregateInitialize( wmInst IN OUT WmConcatRoutines) RETURN number IS
    BEGIN
        wmInst := WmConcatRoutines(0);
        return ODCIConst.Success;
    END;

    MEMBER FUNCTION ODCIAggregateIterate(wmInst IN OUT WmConcatRoutines, value number) return number IS
    BEGIN
        wmInst.tmpData := wmInst.tmpData + value;
        return ODCIConst.Success;
    END;

    MEMBER FUNCTION ODCIAggregateTerminate(wmInst IN WmConcatRoutines, returnValue OUT number, flags IN number) return number IS
    BEGIN
        returnValue := wmInst.tmpData;
        return ODCIConst.Success;
    END;

    MEMBER FUNCTION ODCIAggregateMerge(wmInst IN OUT WmConcatRoutines, wmInst2 IN WmConcatRoutines) return number IS
    BEGIN
        wmInst.tmpData := wmInst.tmpData + wmInst2.tmpData;
        return ODCIConst.Success;
    END;
END;
/

CREATE OR REPLACE FUNCTION WM_CONCAT_test (input number) RETURN number 
    parallel_enable 
    AGGREGATE USING WmConcatRoutines;
/

关于可能导致此问题的任何想法?提前致谢

I'm having this annoying issue with aggregate udfs where it always fails to invoke the iteration method. My code is just like the other examples around the web (including the ones on oracle docs and asktom). I tried to change the UDF type and the same happens everytime. It says:

ORA-29925: cannot execute DBAODB.WMCONCATROUTINES.ODCIAGGREGATEITERATE
ORA-06553: PLS-306: wrong number or types of arguments in call to 'ODCIAGGREGATEITERATE'

Oracle version is 11.1.0.7.0 and Here's my code:

CREATE OR REPLACE TYPE WmConcatRoutines as object (
    tmpData number,

    STATIC FUNCTION ODCIAggregateInitialize( wmInst IN OUT WmConcatRoutines) RETURN number,
    MEMBER FUNCTION ODCIAggregateIterate(wmInst IN OUT WmConcatRoutines, value number) return number,
    MEMBER FUNCTION ODCIAggregateMerge(wmInst IN OUT WmConcatRoutines, wmInst2 IN WmConcatRoutines) return number,
    MEMBER FUNCTION ODCIAggregateTerminate(wmInst IN WmConcatRoutines, returnValue OUT number, flags IN number) return number
);
/

CREATE OR REPLACE TYPE BODY WmConcatRoutines IS 
    STATIC FUNCTION ODCIAggregateInitialize( wmInst IN OUT WmConcatRoutines) RETURN number IS
    BEGIN
        wmInst := WmConcatRoutines(0);
        return ODCIConst.Success;
    END;

    MEMBER FUNCTION ODCIAggregateIterate(wmInst IN OUT WmConcatRoutines, value number) return number IS
    BEGIN
        wmInst.tmpData := wmInst.tmpData + value;
        return ODCIConst.Success;
    END;

    MEMBER FUNCTION ODCIAggregateTerminate(wmInst IN WmConcatRoutines, returnValue OUT number, flags IN number) return number IS
    BEGIN
        returnValue := wmInst.tmpData;
        return ODCIConst.Success;
    END;

    MEMBER FUNCTION ODCIAggregateMerge(wmInst IN OUT WmConcatRoutines, wmInst2 IN WmConcatRoutines) return number IS
    BEGIN
        wmInst.tmpData := wmInst.tmpData + wmInst2.tmpData;
        return ODCIConst.Success;
    END;
END;
/

CREATE OR REPLACE FUNCTION WM_CONCAT_test (input number) RETURN number 
    parallel_enable 
    AGGREGATE USING WmConcatRoutines;
/

Any ideas on what may be causing this? thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

污味仙女 2025-01-08 02:29:23

ODCI 函数实现中的参数名称必须与 文档;因此您必须使用 sctxselfctx2 而不是 wminstwminst2 >。

编辑 正如 APC 简要提到的,似乎只需要 self ;您可以使用其他东西来代替 sctxctx2。我找不到文档参考...

编辑 2 是的,我可以... APC 对其作为对象的引用使我想到

The parameter names in your implementations of the ODCI functions have to match those in the documentation; so you have to use sctx, self, and ctx2 rather than wminst and wminst2.

Edit As APC briefly mentioned, it only seems to be self that is required; you can use something else in place of sctx and ctx2. I can't find a documentation reference...

Edit 2 Yes, I can... APC's reference to it being an object thing led me to this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文