Dapper - Stored procedure oracle doesn't return result, if more two OUT parameters

dapper out-parameters stored-procedures

Question

Can help me. I don't get result in My code? if I'm using Dapper.

using(var connection = new OracleConnection("User ID=TEST;Password=TEST;data source=R_TEST"))
        {
                connection.Open();

                var p = new OracleDynamicParameters();
                p.Add("V_IN", "123456789874");
                p.Add("VO_T1", dbType: DbType.Int32, direction: ParameterDirection.Output);
                p.Add("VO_T2", dbType: DbType.Varchar2, direction: ParameterDirection.Output);
                p.Add("VO_T3", dbType: DbType.Int32, direction: ParameterDirection.Output);
                p.Add("VO_T4", dbType: DbType.Varchar2, direction: ParameterDirection.Output);
                p.Add("VO_T5", dbType: DbType.Varchar2, direction: ParameterDirection.Output);

                var result = connection.Query("WS_PKG.MY_PROCEDURE", p, commandType:  CommandType.StoredProcedure);
       }

Byt if I try get result using hand code. Use SqlDataReader. I get result successful.

Look at this code. there I'm using with SqlDataReader:

connection.Open();


                    OracleCommand command = new OracleCommand("WS_PKG.GETINFOFROMNBBYIIN", connection);
                    command.CommandType = CommandType.StoredProcedure;
                    command.BindByName = true;

                    command.Parameters.Add("V_IN", OracleDbType.Varchar2, 25, iin, ParameterDirection.Input);
                    var VO_T1 = command.Parameters.Add("VO_T1", OracleDbType.Int32, 10, default(int), ParameterDirection.Output);
                    var VO_T2 = command.Parameters.Add("VO_T2", OracleDbType.Varchar2, 1024, default(string), ParameterDirection.Output);
                    var VO_T3 = command.Parameters.Add("VO_T3", OracleDbType.Int32, 10, default(int), ParameterDirection.Output);
                    var VO_T4 = command.Parameters.Add("VO_T4", OracleDbType.Varchar2, 1024, default(string), ParameterDirection.Output);
                    var VO_T5 = command.Parameters.Add("VO_T5", OracleDbType.Varchar2, 1024, default(string), ParameterDirection.Output);


                    command.ExecuteNonQuery();

Thank you for your help guys.

Popular Answer

Good day. I forgot add size variable. Look at the example code:

enter code hereusing(var connection = new OracleConnection("User ID=TEST;Password=TEST;data source=R_TEST"))
    {
            connection.Open();

            var p = new OracleDynamicParameters();
            p.Add("V_IN", "123456789874");
            p.Add("VO_T1", dbType: DbType.Int32, direction: ParameterDirection.Output, size: 1);
            p.Add("VO_T2", dbType: DbType.Varchar2, direction: ParameterDirection.Output, size: 4000);
            p.Add("VO_T3", dbType: DbType.Int32, direction: ParameterDirection.Output,size: 1);
            p.Add("VO_T4", dbType: DbType.Varchar2, direction: ParameterDirection.Output,size: 50);
            p.Add("VO_T5", dbType: DbType.Varchar2, direction: ParameterDirection.Output, size: 50);

            var result = connection.Query("WS_PKG.MY_PROCEDURE", p, commandType:  CommandType.StoredProcedure);
   }

We must add size variable. Thank you everyone. I decided this question.



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why