这是我的存储过程(简单地尝试隔离问题,所以我现在正在做的就是设置OUT参数):
PROCEDURE DequeuePPLPlatformMsg( msgType OUT VARCHAR2, msgBody OUT VARCHAR2) IS BEGIN
msgType := 'TESTTYPE';
msgBody := 'TESTBODY';
END DequeuePPLPlatformMsg;
这是我的C#代码,用于调用存储过程并尝试获取OUT参数中的值:
OConn = new OracleConnection();
OConn.ConnectionString = "Password=mypw; User ID=myid; Data Source=devdb;";
OConn.Open();
OComm = new OracleCommand(StoredProc, OConn);
OComm.CommandType = System.Data.CommandType.StoredProcedure;
OComm.Parameters.Add("msgType", OracleDbType.Varchar2, 255, System.Data.ParameterDirection.Output);
OComm.Parameters.Add("msgBody", OracleDbType.Varchar2, 255, System.Data.ParameterDirection.Output);
int Result = OComm.ExecuteNonQuery();
OConn.Close();
String msgType = OComm.Parameters["msgType"].Value.ToString();
String msgBody = OComm.Parameters["msgBody"].Value.ToString();
当我查看参数中的值时,它们包含空字符串。
有什么想法吗?谢谢!
答案 0 :(得分:1)
对不起,这是详细信息......
这是存储过程:
程序DequeuePPLPlatformMsg(msgType OUT VARCHAR2,msgBody OUT VARCHAR2)已开始
msgType := 'TESTTYPE';
msgBody := 'TESTBODY';
END DequeuePPLPlatformMsg;
这是C#代码:
OConn = new OracleConnection();
OConn.ConnectionString = "Password=mypw; User ID=myid; Data Source=devdb;";
OConn.Open();
OComm = new OracleCommand(StoredProc, OConn);
OComm.CommandType = System.Data.CommandType.StoredProcedure;
OracleParameter msgTypeParam = new OracleParameter("msgType", OracleDbType.Varchar2);
msgTypeParam.Direction = System.Data.ParameterDirection.Output;
msgTypeParam.Value = "";
msgTypeParam.Size = 255;
OComm.Parameters.Add(msgTypeParam);
OracleParameter msgBodyParam = new OracleParameter("msgBody", OracleDbType.XmlType);
msgBodyParam.Direction = System.Data.ParameterDirection.Output;
OComm.Parameters.Add(msgBodyParam);
int Result = OComm.ExecuteNonQuery();
OConn.Close();
String msgType = msgTypeParam.Value.ToString();
msgType是String.Empty
谢谢!
答案 1 :(得分:0)
您是否尝试过按值访问它?
Dim retValParam As New OracleClient.OracleParameter("p_retVal", OracleClient.OracleType.VarChar)
retValParam.Direction = ParameterDirection.Output
retValParam.Size = 100
retValParam.Value = ""
command.Parameters.Add(retValParam)
command.ExecuteNonQuery()
retVal = retValParam.Value