Reputation: 5628
I would like to call a (Oracle) Procedure from C#. My Code:
try
{
OracleConnection myOracleConnection = new OracleConnection(connectionString);
myOracleConnection.Open();
OracleCommand command = myOracleConnection.CreateCommand();
command.CommandText = String.Format("BEGIN MISSINGTABLES ('{0}', '{1}'); END;", "PEKA_ERP_001", "ASE_ERP_001");
command.CommandType = System.Data.CommandType.Text;
command.ExecuteNonQuery();
myOracleConnection.Close();
}
catch (OracleException e)
{
throw e;
}
catch (Exception e)
{
throw e;
}
The Procedure:
CREATE OR REPLACE PROCEDURE MISSINGTABLES (S1 IN VARCHAR2, S2 IN VARCHAR2) AS
BEGIN [...]
on command.ExecuteNonQuery();
I get an Exception..:
PL/SQL: Statement ignored
OracleException Unhandled
What I'm doing wrong?
Upvotes: 0
Views: 7740
Reputation: 5628
Did it :)
OracleCommand command = myOracleConnection.CreateCommand();
command.CommandText = "MISSINGTABLES";
command.Parameters.Add(new OracleParameter("S1", OracleType.VarChar)).Value = "PEKA_ERP_001";
command.Parameters.Add(new OracleParameter("S2", OracleType.VarChar)).Value = "ASE_ERP_001";
command.CommandType = System.Data.CommandType.StoredProcedure;
command.ExecuteNonQuery();
myOracleConnection.Close();
Upvotes: 1