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

时间:2012-01-31 17:20:19

标签: oracle plsql aggregate user-defined-functions ora-06553

我遇到了这个恼人的聚合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;
/

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

1 个答案:

答案 0 :(得分:3)

ODCI函数实现中的参数名称必须与documentation中的参数名称相匹配;所以你必须使用sctxselfctx2而不是wminstwminst2

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

编辑2 是的,我可以...... APC将其作为对象的引用引导我this