2013-07-24 29 views
0

我想在Oracle數據庫中編寫一個函數。當我在函數編輯器中並嘗試運行它時,DbVis將插入一個附加參數。DbVisualizer插入一個參數到我的Oracle數據庫函數調用

@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返回類型也是我創建的類型。這是 'CREATE OR REPLACE TYPE 「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],我如何擺脫它?或者,請告訴我我要離開的東西,也許

謝謝。

回答

0

我從DbVisualizer收到郵件,他們的編輯器無法識別自定義數據類型,這正是我所嘗試的。所以,留在本地類型,你沒事。