0

这是我的存储过程(使尝试隔离问题变得简单,所以我现在要做的就是设置 OUT 参数):

PROCEDURE DequeuePPLPlatformMsg (msgType OUT VARCHAR2, msgBody OUT VARCHAR2) 开始

    msgType := 'TESTTYPE';
    msgBody := 'TESTBODY';

END DequeuePPLPlatformMsg;

这是我调用存储过程并尝试获取 OUT 参数中的值的 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;

        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();

当我查看参数中的值时,它们包含空字符串。

有任何想法吗?谢谢!!

4

2 回答 2

1

对不起,这里是详细信息...

这是存储过程:

PROCEDURE 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

谢谢!

于 2013-06-27T18:36:14.270 回答
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
于 2013-03-08T15:38:21.173 回答