我們有一個駐留在oracle 10.2數據庫中的oracle存儲過程。存儲的程序包含特定的輸入和輸出參數。我們正在嘗試創建一個asp.net web應用程序來執行存儲過程,並將來自輸出參數的結果綁定到一個gridview中。但沒有運氣。使用asp.net調用oracle存儲過程。 Visual Studio 2005
這是我迄今所做
Oracle.DataAccess.dll
我與Oracle開發工具Visual Studio已安裝了Oracle數據訪問組件(ODAC),並用它來調用oracle存儲過程。
**這是我得到**
ORA-06550錯誤:第1行,第7列:
PLS-00306:錯號碼或類型的呼叫參數 'CALC_NUMBERVOTES'
ORA-06550 :第1行,第7列:
PLS-00306:錯誤數量或類型的呼叫參數 'CALC_NUMBERVOTES'
ORA-06550:第1行,第7列:
PLS-00306:錯誤的號碼或類型的參數來電 'CALC_NUMBERVOTES'
ORA-06550:第1行,第7列:
PLS-00306 :錯誤的數量或類型的呼叫參數 'CALC_NUMBERVOTES'
ORA-06550:第1行,第7列:
PL/SQL:語句被忽略
任何幫助非常感謝。
oralce的存儲過程代碼
PROCEDURE calc_numbervotes (
i_Office IN ELECTIONRESULTS.office%TYPE,
o_candidate OUT tblcandidate ,
o_party OUT tblparty,
o_votes OUT tblvotes,
o_percAll OUT tblpercAll)
IS
/***************Find Number of candidate per office and party******************/
CURSOR c1 is
SELECT distinct candidate, party,sum(votes) totalvotes
FROM ELECTIONRESULTS
WHERE candidate not in ('Registered Voters')
AND office = i_office
AND Precinct <> ' '
GROUP BY candidate,party
ORDER BY sum(votes) desc;
/****************** Find total county votes per candidate *********************/
CURSOR c2 is
SELECT sum(votes) from ELECTIONRESULTS
WHERE candidate !='Registered Voters'
AND office = i_Office
AND Precinct <> ' ';
recCount NUMBER DEFAULT 0;
totvotesall NUMBER;
totvotescandidateprec NUMBER;
BEGIN
OPEN c2;
FETCH c2 into totvotesall;
CLOSE c2;
************************************************************/
FOR rec in c1 LOOP
recCount:= recCount + 1;
o_candidate(recCount):= rec.candidate;
o_party(recCount) := rec.party;
o_votes(recCount) := rec.totalvotes;
if rec.totalvotes = 0 then
o_percAll(recCount) := 0;
else
o_percAll(recCount) := round((rec.totalvotes/totvotesall)*100,2);
end if;
END LOOP;
END calc_numbervotes;
asp.net代碼
Dim constr As String = "data source=ds;user id=uid;password=pwd;"
Dim orclCon As OracleConnection
orclCon = New OracleConnection(constr)
Dim objCmd As OracleCommand = New OracleCommand()
objCmd.Connection = orclCon
objCmd.CommandText = "pkg_calc_votes.calc_numbervotes"
objCmd.CommandType = CommandType.StoredProcedure
objCmd.Parameters.Add(New OracleParameter("i_office", OracleDbType.NVarchar2, 255)).Value = "U.S. CONGRESS 05"
objCmd.Parameters.Add(New OracleParameter("o_party", OracleDbType.NVarchar2, 10)).Direction = ParameterDirection.Output
objCmd.Parameters.Add(New OracleParameter("o_candidate", OracleDbType.NVarchar2, 255)).Direction = ParameterDirection.Output
objCmd.Parameters.Add(New OracleParameter("o_votes", OracleDbType.Decimal, 10)).Direction = ParameterDirection.Output
objCmd.Parameters.Add(New OracleParameter("o_percAll", OracleDbType.Double, 10)).Direction = ParameterDirection.Output
orclCon.Open()
Dim orclDtRdr As OracleDataReader = Nothing
orclDtRdr = objCmd.ExecuteReader()
gvCursor.DataSource() = orclDtRdr
gvCursor.DataBind()
orclDtRdr.Close()
orclCon.Close()
所存儲proceder從表中選擇數據庫中的所有數據,除了一個值,其中_o_percAll_。該參數正在sp中進行計算。
謝謝 教育暨青年局
你的參數類型似乎並不匹配: NVARCHAR2 <> tblCandidate – 2010-08-05 20:27:22
爲什麼需要在存儲過程的輸出參數?爲什麼不返回單個結果集? – 2010-08-05 20:36:50