带有参数的C#OracleCommand SQL调用过程
本文关键字:SQL 调用 过程 C#OracleCommand 参数 | 更新日期: 2023-09-27 18:20:38
我想从C#调用一个(Oracle)过程。我的代码:
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;
}
程序:
CREATE OR REPLACE PROCEDURE MISSINGTABLES (S1 IN VARCHAR2, S2 IN VARCHAR2) AS
BEGIN [...]
在command.ExecuteNonQuery();
上,我得到一个异常..:
PL/SQL: Statement ignored
OracleException Unhandled
我做错了什么?
是否:)
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();