I'm doing a test to find out how to call a procedure that has this type of course.
IntheprocedureIhavethis:
createorreplacePROCEDURE"PTESTE"
(
pcd_servicoagendado integer,
ptipo integer, -- 0 principal, 1 debitos
p_cursor out pkgcursor.t_cursor
).....
In my project I have:
namespace Generico.Aplicacao
{
public class AtualizaAplicacao
{
private Contexto contexto;
public void TesteConsultaSql()
{
string servico = "30864";
string tipo = "0";
var strQuery = "";
strQuery += " PTESTE";
strQuery += string.Format(" @pcd_servicoagendado = '{0}' , ", servico);
strQuery += string.Format(" @ptipo = '{0}' ", tipo);
using (contexto = new Contexto())
{
var retornoDataReader = contexto.ExecutaComandoComRetorno(strQuery);
}
}
}
}
My Repository
namespace Generico.Repositorio
{
public class Contexto : IDisposable
{
private readonly OracleConnection minhaConexao;
public Contexto()
{
minhaConexao = new OracleConnection(ConfigurationManager.ConnectionStrings["Conexao"].ConnectionString);
minhaConexao.Open();
}
public void ExecutaComando(string strQuery)
{
var cmdComando = new OracleCommand
{
CommandText = strQuery,
CommandType = CommandType.Text,
Connection = minhaConexao
};
cmdComando.ExecuteNonQuery();
}
public OracleDataReader ExecutaComandoComRetorno(string strQuery)
{
var cmdComando = new OracleCommand(strQuery, minhaConexao);
cmdComando.Parameters.Add("P_CURSOR", OracleType.Cursor).Direction = ParameterDirection.Output;
return cmdComando.ExecuteReader();
}
public void Dispose()
{
if (minhaConexao.State == ConnectionState.Open)
minhaConexao.Close();
}
}
}