Doubt to show data in c # from an sp in oracle

0

Good afternoon I have a question related to ac # and oracle, well I have several procedures stored in an Oracle database (Oracle 11G) in several of these some with input parameters and others that only show everything (select * From name) , my question is how do I capture the oracle sp and show all its data in c #, since in the way I do I get the error of " wrong number or types of arguments in call to 'SPLISTARCLIENTES' "I'll give you some of the examples I have.

CREATE OR REPLACE PROCEDURE SPLISTARCLIENTES
(pruebaRecords OUT SYS_REFCURSOR)AS 
BEGIN
  OPEN pruebaRecords FOR
      SELECT * 
      FROM CLIENTE;      
END SPLISTARCLIENTES;

and the code of c # (the labels only I have to check if it brings data or not)

 OracleConnection cnn = new OracleConnection("Data Source = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = xe))); User Id = xxxxxx; Password = xxxxxx; Pooling = true; Max Pool Size = 10; Min Pool Size = 1");
            string sql = "SPLISTARCLIENTES";
            OracleConnection cn = cnn;

            OracleCommand cmd = new OracleCommand(sql,cn);
            cmd.CommandType = CommandType.StoredProcedure;

                                   try
            {
                cn.Open();
                cmd.ExecuteReader();


                OracleDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    Label1.Text = Convert.ToString(reader[0]);
                }
            }
            catch(Exception ex)
            {
                Label2.Text = Convert.ToString(ex);
            }
            finally
            {
                cn.Close();
                cmd.Dispose();
                cn.Dispose();
            }            

I hope someone can help me thanks.

    
asked by NPavel 23.10.2017 в 00:56
source

1 answer

1

you must specify the sysrefcursor parameter as follows

OracleParameter p_rc = cmd.Parameters.Add("pruebaRecords ",
    OracleDbType.RefCursor,
    DBNull.Value,
    ParameterDirection.Output);
    
answered by 24.10.2017 / 00:23
source