0

我正在尝试在 Oracle 数据库中编写一个函数。当我在函数编辑器中并尝试运行它时,DbVis 会插入一个附加参数。

@call [dbvis - v0] = SP_GET_ANNUAL_SALES_HISTORY( [dbvis - v1], 'DAL', '00105315', '2013' );
@echo returnValue = [dbvis - v0];
@echo p1 = [dbvis - v0];

然后我得到这个错误:

... Physical database connection acquired for: JdaTest
10:36:40  [@CALL - 0 row(s), 0.000 secs]  [Error Code: 6550, SQL State: 65000]  ORA-06550: line 1, column 13:
PLS-00306: wrong number or types of arguments in call to 'SP_GET_ANNUAL_SALES_HISTORY'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
10:36:40  [@ECHO - 0 row(s), 0.000 secs]  returnValue = null
10:36:40  [@ECHO - 0 row(s), 0.000 secs]  p1 = null
... 3 statement(s) executed, 0 row(s) affected, exec/fetch time: 0.000/0.000 sec  [2 successful, 0 warnings, 1 errors]

这是我的功能。这是我第一次涉足存储过程。在这一点上,我只是想让它运行并提供一些结果。hte 返回类型是我也创建的类型。它是'创建或替换类型“SAPMGR”。“ANNUAL_SALES_HISTORY”是数字的 Varray(12)'

CREATE OR REPLACE FUNCTION "SAPMGR"."SP_GET_ANNUAL_SALES_HISTORY" (loc_in IN varchar2,item_in IN varchar2,year_in IN varchar2)
RETURN annual_sales_history
AS
        yearStart       Date;
        yearEnd         Date;
        start_date      sales_history.start_date%TYPE;
        qty             sales_history.quantity%TYPE;
        ash             annual_sales_history;        

        cursor c1 is
        select start_date,QTY 
        from sales_history
        where item = item_in
          and loc = loc_in
          and start_date between yearStart and yearEnd
        order by item, loc, start_date;

BEGIN
        Loop
                fetch c1 into start_date, qty;
                exit when c1%notfound;
                ash(extract(month from start_date)) := qty;

                DBMS_OUTPUT.PUT_LINE( 'ash' || ' ' || ash(0) || ' ' || ash(1) || ' ' || ash(2) || ' ' || ash(3) || ' ' || ash(4) || ' ' || ash(5)|| ' ' || ash(6) || ' ' || ash(7));      
        End loop

        commit;
        close c1;
EXCEPTION
WHEN OTHERS THEN
   raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);        

        RETURN ash;
 END;

什么是 [dbvis - v1],我该如何摆脱它?或者,请告诉我我在哪里遗漏了一些东西

谢谢。

4

1 回答 1

0

我收到了来自 DbVisualizer 的邮件,说他们的编辑器无法识别自定义数据类型,而这正是我所尝试的。所以,保持原生类型,你就可以了。

于 2013-07-25T15:07:27.993 回答