try
{
string sql = @"declare
P_POL_NBR VARCHAR2(20);
V_MSG VARCHAR2(1000);
V_FLAG NUMBER;
V_ID NUMBER;
P_RECYC_POL_ID NUMBER;
P_EXEC_STATUS ABC.PKG_RECORDSET_TYPE.PROC_EXE_STAT_TYP;
begin
P_POL_NBR:='000000123';
ABC.USPSVRFY( P_POL_NBR,P_RECYC_POL_ID, P_EXEC_STATUS);
OPEN :1 FOR SELECT P_EXEC_STATUS.Excp_msg,P_EXEC_STATUS.Excp_flag,P_EXEC_STATUS.Errlog_Id INTO
V_MSG,V_FLAG,V_ID FROM DUAL;
end;";
ProviderFactory pf = new ProviderFactory(ProviderType.OracleClient);
using (IDbConnection conn = pf.CreateConnection("Data Source=XXX;Password=XXX;User ID=XXX"))
{
IDbCommand cmd = pf.CreateCommand(sql, conn);
IDataParameter p_1 = pf.CreateDataParameter("1", OracleType.Cursor);
p_1.Direction = ParameterDirection.Output;
cmd.Parameters.Add(p_1);
cmd.CommandType = CommandType.Text; //Database store procedure
conn.Open();
IDataReader odr = cmd.ExecuteReader();
while (odr.Read())
{
Console.WriteLine("DEPTNO: {0}", odr[0].ToString());
Console.WriteLine(" DNAME: {0}", odr[1].ToString());
Console.WriteLine(" LOC: {0}", odr[2].ToString());
Console.WriteLine();
}
odr.Close();
conn.Close();
Console.ReadLine();
}
Console.ReadLine();
}
catch (SystemException e)
{
Console.Error.WriteLine(e.Message);
}
{
string sql = @"declare
P_POL_NBR VARCHAR2(20);
V_MSG VARCHAR2(1000);
V_FLAG NUMBER;
V_ID NUMBER;
P_RECYC_POL_ID NUMBER;
P_EXEC_STATUS ABC.PKG_RECORDSET_TYPE.PROC_EXE_STAT_TYP;
begin
P_POL_NBR:='000000123';
ABC.USPSVRFY( P_POL_NBR,P_RECYC_POL_ID, P_EXEC_STATUS);
OPEN :1 FOR SELECT P_EXEC_STATUS.Excp_msg,P_EXEC_STATUS.Excp_flag,P_EXEC_STATUS.Errlog_Id INTO
V_MSG,V_FLAG,V_ID FROM DUAL;
end;";
ProviderFactory pf = new ProviderFactory(ProviderType.OracleClient);
using (IDbConnection conn = pf.CreateConnection("Data Source=XXX;Password=XXX;User ID=XXX"))
{
IDbCommand cmd = pf.CreateCommand(sql, conn);
IDataParameter p_1 = pf.CreateDataParameter("1", OracleType.Cursor);
p_1.Direction = ParameterDirection.Output;
cmd.Parameters.Add(p_1);
cmd.CommandType = CommandType.Text; //Database store procedure
conn.Open();
IDataReader odr = cmd.ExecuteReader();
while (odr.Read())
{
Console.WriteLine("DEPTNO: {0}", odr[0].ToString());
Console.WriteLine(" DNAME: {0}", odr[1].ToString());
Console.WriteLine(" LOC: {0}", odr[2].ToString());
Console.WriteLine();
}
odr.Close();
conn.Close();
Console.ReadLine();
}
Console.ReadLine();
}
catch (SystemException e)
{
Console.Error.WriteLine(e.Message);
}
No comments:
Post a Comment