سؤال

Here is my stored proc (made it simple to try to isolate the issue, so all I'm doing now is setting the OUT params):

PROCEDURE DequeuePPLPlatformMsg ( msgType OUT VARCHAR2, msgBody OUT VARCHAR2) IS BEGIN

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

END DequeuePPLPlatformMsg;

Here is my C# code to call the stored proc and attempt to get the values in the OUT params:

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

When I look at the Values in the params, they contain empty strings.

Any ideas? Thanks!!

هل كانت مفيدة؟

المحلول

Sorry, here are the details...

This is the stored proc:

PROCEDURE DequeuePPLPlatformMsg ( msgType OUT VARCHAR2, msgBody OUT VARCHAR2) IS BEGIN

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

END DequeuePPLPlatformMsg;

This is the C# code:

        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 is String.Empty

Thanks!

نصائح أخرى

Have you tried to simply access it by value?

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
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top