存储过程
create or replace PACKAGE BODY LOGGER IS PROCEDURE LOG
(abcd OUT INT,abcd1 INT,abcd2 INT,abcd3 VARCHAR2,abcd4 VARCHAR2,abcd5 DATE,
abcd6 VARCHAR2,abcd7 VARCHAR2,abcd8 VARCHAR2,abcd9 VARCHAR2,abcd10 VARCHAR2,
abcd10 VARCHAR2,abcd11 VARCHAR2,abcd12 VARCHAR2, abcd13 VARCHAR2)
IS BEGIN
INSERT INTO LOG (abcd,abcd1,abcd2,abcd3,abcd4,abcd5,abcd6,abcd7,abcd8
abcd9,abcd10,abcd11,abcd12,abcd13)
VALUES (0,CAST (LOG.abcd AS NUMBER (10)),CAST (LOG.abcd1 AS NUMBER (10)),
LOG.abcd2,LOG.abcd3,LOG.abcd4,LOG.abcd5,LOG.abcd6,LOG.abcd7,LOG.abcd8,
LOG.abcd9,LOG.abcd10,LOG.abcd11,LOG.abcd12);
SELECT LOG_SEQ.CURRVAL INTO LOG.abcd FROM DUAL;
END LOG;
logging.cs 文件
private int ExecuteWriteLogStoredProcedure(LogEntry logEntry, Database db, DbTransaction transaction)
{
OracleAdapter adapter = new OracleAdapter();
var con = adapter.OpenConnection();
var cmd = adapter.CreateSpCommand(con, this.writeLogStoredProcName);
cmd.Parameters.Add("abcd", OracleDbType.Int32, 4,ParameterDirection.Output);
cmd.Parameters.Add("abcd1", OracleDbType.Int32, logEntry.abcd1,ParameterDirection.Input);
cmd.Parameters.Add("abcd2", OracleDbType.Int16, logEntry.abcd2, ParameterDirection.Input);
cmd.Parameters.Add("abcd3", OracleDbType.Varchar2,32,ParameterDirection.Input,false,(byte)0, (byte)0, (string)null, DataRowVersion.Default, (object)logEntry.abcd3.ToString());
cmd.Parameters.Add("abcd4", OracleDbType.Varchar2, 256, ParameterDirection.Input, false, (byte)0, (byte)0, (string)null, DataRowVersion.Default, (object)logEntry.abcd4);
cmd.Parameters.Add("abcd5", OracleDbType.TimeStamp, logEntry.TimeStamp,ParameterDirection.Input);
cmd.Parameters.Add("abcd6", OracleDbType.Varchar2, 32, ParameterDirection.Input, false, (byte)0, (byte)0, (string)null, DataRowVersion.Default, (object)logEntry.abcd6);
cmd.Parameters.Add("abcd7", OracleDbType.Varchar2, 512, ParameterDirection.Input, false, (byte)0, (byte)0, (string)null, DataRowVersion.Default, (object)logEntry.abcd7);
cmd.Parameters.Add("abcd8", OracleDbType.Varchar2, 256, ParameterDirection.Input, false, (byte)0, (byte)0, (string)null, DataRowVersion.Default, (object)logEntry.abcd8);
cmd.Parameters.Add("abcd9", OracleDbType.Varchar2, 512, ParameterDirection.Input, false, (byte)0, (byte)0, (string)null, DataRowVersion.Default, (object)logEntry.abcd9);
cmd.Parameters.Add("abcd10", OracleDbType.Varchar2, 512, ParameterDirection.Input, false, (byte)0, (byte)0, (string)null, DataRowVersion.Default, (object)logEntry.abcd10);
cmd.Parameters.Add("abcd11", OracleDbType.Varchar2, 128, ParameterDirection.Input, false, (byte)0, (byte)0, (string)null, DataRowVersion.Default, (object)logEntry.abcd11);
cmd.Parameters.Add("abcd12", OracleDbType.Varchar2, 1500, ParameterDirection.Input, false, (byte)0, (byte)0, (string)null, DataRowVersion.Default, (object)logEntry.abcd12);
if (this.Formatter != null)
cmd.Parameters.Add("formattedmessage", OracleDbType.Varchar2, this.Formatter.Format(logEntry),ParameterDirection.Input);
else
cmd.Parameters.Add("formattedmessage", OracleDbType.Varchar2, (object)logEntry.Message, ParameterDirection.Input);
cmd.ExecuteNonQuery();
return Convert.ToInt32(cmd.Parameters[0].Value, (IFormatProvider)CultureInfo.InvariantCulture);
}
我收到错误
cmd.Parameters.Add("abcd2", OracleDbType.Int32, logEntry.abcd2, ParameterDirection.Input);
logEntry.abcd2 的值为 0x000000000 并且我的表中的优先级不为空。如何解决这个错误?请帮忙 。任何线索都会有所帮助。