嗨,我写了这段代码来创建一个过程来返回refcursor数据,当从VB.NET中调用这个过程时,我得到了这样的错误信息
ORA-06550:第1行,第15列:PLS-00306:在调用'GET_OA_FOR_ATT_TAB'时,参数的数量或类型错误 ORA-06550:第1行,第7列:PLSQL: 语句被忽略
以下是我的程序
PROCEDURE GET_OA_FOR_ATT_TAB
(
prmOptIdent IN T,
prmMajModel IN string,
prmMinModel IN string,
prmGOOutOptionCursor OUT Global_Package.REF_CUR,
prmAMOOutOptionCursor OUT Global_Package.REF_CUR,
prmOVOutOptionCursor OUT Global_Package.REF_CUR
)
AS
i NUMBER := prmOptIdent.FIRST;
identsTable string_table := string_table(null);
BEGIN
identsTable.EXTEND(prmOptIdent.COUNT);
IF i IS NOT NULL THEN
LOOP
identsTable(i) := prmOptIdent(i);
i := prmOptIdent.NEXT(i);
EXIT WHEN i IS NULL;
END LOOP;
END IF;
OPEN prmGOOutOptionCursor FOR
SELECT G.OPT_IDENT, G.OPT_NO_IDENT, G.Opt_Ttl_Nm, GetFullNoteText(G.OPT_NARR_NT_IDENT) AS OPT_NARR_NT_TEXT,
G.Opt_Ph_Txt, G.Opt_Gen_Typ_Cd, G.OPT_LIMITED_USE_IND, G.OPT_INTL_IND,
OC.CAT_IDENT, C.CAT_NM
FROM GENERIC_OPTION G, OPTION_CATEGORY OC, CATEGORY C
WHERE G.OPT_IDENT in
(select column_value from table(identsTable)) AND
G.OPT_IDENT = OC.OPT_IDENT (+) AND
OC.CAT_IDENT = C.CAT_IDENT (+)
ORDER BY G.OPT_NO_IDENT;
OPEN prmAMOOutOptionCursor FOR
Do something
OPEN prmOVOutOptionCursor FOR
Do something
END GET_OA_FOR_ATT_TAB;
这是我的代码,从VB.NET cole过程。
Dim conn As New OracleConnection(objOptionInfoEntity.ConnectionName)
Dim cmd As New OracleCommand()
cmd.Connection = conn
cmd.CommandText = ConfigCommon.GetStoredProc(configDB.ToString(), GlobalConstants.SP_CONFIG_GET_OA_FOR_ATT_TAB)
cmd.CommandType = CommandType.StoredProcedure
Dim optionParameter As New OracleParameter
optionParameter.ParameterName = "@prmOptIdent"
optionParameter.OracleDbType = OracleDbType.Varchar2
optionParameter.Direction = ParameterDirection.Input
Dim param() As String
param = ConfigCommon.CreateXMLForArrayForAttTab(OATable, "Sub_Opt_Ident")
optionParameter.CollectionType = OracleCollectionType.PLSQLAssociativeArray
optionParameter.Value = param
optionParameter.Size = param.Length
cmd.Parameters.Add(optionParameter)
Dim majorModel As New OracleParameter
majorModel.ParameterName = "@prmMajModel"
majorModel.OracleDbType = OracleDbType.Varchar2
majorModel.Direction = ParameterDirection.Input
majorModel.Value = objOptionInfoEntity.AirplaneModelOptionInfo.AirplaneModelOption.MajorModelIdent.Trim
cmd.Parameters.Add(majorModel)
Dim minorModel As New OracleParameter
minorModel.ParameterName = "@prmMinModel"
minorModel.OracleDbType = OracleDbType.Varchar2
minorModel.Direction = ParameterDirection.Input
minorModel.Value = objOptionInfoEntity.AirplaneModelOptionInfo.AirplaneModelOption.MinorModelIdent.Trim
cmd.Parameters.Add(minorModel)
Dim GOOutOptionCursor As New OracleParameter
GOOutOptionCursor.ParameterName = "@prmGOOutOptionCursor"
GOOutOptionCursor.OracleDbType = OracleDbType.RefCursor
GOOutOptionCursor.Direction = ParameterDirection.ReturnValue
cmd.Parameters.Add(GOOutOptionCursor)
Dim AMOutOptionCursor As New OracleParameter
AMOutOptionCursor.ParameterName = "@prmAMOOutOptionCursor"
GOOutOptionCursor.OracleDbType = OracleDbType.RefCursor
AMOutOptionCursor.Direction = ParameterDirection.ReturnValue
cmd.Parameters.Add(AMOutOptionCursor)
Dim OVOutOptionCursor As New OracleParameter
OVOutOptionCursor.ParameterName = "@prmOVOutOptionCursor"
GOOutOptionCursor.OracleDbType = OracleDbType.RefCursor
OVOutOptionCursor.Direction = ParameterDirection.ReturnValue
cmd.Parameters.Add(OVOutOptionCursor)
Dim da As New OracleDataAdapter(cmd)
da.Fill(ds)
我在网上看到建议我检查数据类型的命名,并在包中声明一个关联数组,我做了,但没有任何变化。任何想法?先谢谢你
我想你需要类似的东西。
Dim OVOutOptionCursor As New OracleParameter
OVOutOptionCursor.ParameterName = "@prmOVOutOptionCursor"
OVOutOptionCursor.OracleDbType = OracleDbType.RefCursor ' check your code for copy paste errors. This line says GOOptionCursor in your code
OVOutOptionCursor.Direction = ParameterDirection.Out
cmd.Parameters.Add(OVOutOptionCursor)
cmd.ExecuteNonQuery()
Dim dt as New DataTable
dt.Load(DirectCast(OVOutOptionCursor, IDataReader))
但我没有办法测试它