J
Jonaze
I have a function with the following code, I have written this function
with the example provided in the documentation provided with
OracleClient.
The called stored procedure functions perfectly, I have tested it
manually with success, but when I try to use the function, I get the
error "Object must implement IConvertible".
I also tested with the code in comment, without success and the same
result. If anyone has an idea...
int fileLength = Convert.ToInt32(_BinaryFile.Length);
byte[] fileBinary = new byte[fileLength];
int status = _BinaryFile.Read(fileBinary, 0, fileLength);
_BinaryFile.Close();
OracleConnection oc = new
OracleConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
oc.Open();
OracleTransaction tx = oc.BeginTransaction();
OracleCommand ocm = oc.CreateCommand ();
ocm.Transaction = tx;
/*
ocm.CommandText = "declare xx blob; begin dbms_lob.createtemporary(xx,
false, 0); :tempblob := xx; end;";
ocm.Parameters.Add(new OracleParameter("tempblob",
OracleType.Blob)).Direction = ParameterDirection.Output;
ocm.ExecuteNonQuery();
OracleLob ol = (OracleLob)ocm.Parameters[0].Value;
ol.BeginBatch(OracleLobOpenMode.ReadWrite);
ol.Write(fileBinary, 0, fileLength);
ol.EndBatch();
*/
ocm.Parameters.Clear();
ocm.CommandText = PUT_FILE; //Constant
ocm.CommandType = CommandType.StoredProcedure;
ocm.Parameters.Add( new OracleParameter("PROCESS_ID",
OracleType.VarChar, 36)).Value = _ProcessID;
ocm.Parameters.Add( new OracleParameter("NSB", OracleType.VarChar,
15)).Value = _NSB;
ocm.Parameters.Add( new OracleParameter("GENERATION_DATE",
OracleType.DateTime)).Value = _Date;
if (_AllPublication)
ocm.Parameters.Add( new OracleParameter("ALLPUBLICATION",
OracleType.Number)).Value = 1;
else
ocm.Parameters.Add( new OracleParameter("ALLPUBLICATION",
OracleType.Number)).Value = 0;
ocm.Parameters.Add( new OracleParameter("FILTERED",
OracleType.Number)).Value = _Filtered;
ocm.Parameters.Add( new OracleParameter("DATE_FROM",
OracleType.DateTime)).Value = _DateFrom;
ocm.Parameters.Add( new OracleParameter("DATE_TO",
OracleType.DateTime)).Value = _DateTo;
ocm.Parameters.Add( new OracleParameter("FILE_FORMAT",
OracleType.VarChar, 3)).Value = _Format;
ocm.Parameters.Add( new OracleParameter("PATH", OracleType.VarChar,
500)).Value = _Path;
ocm.Parameters.Add( new OracleParameter("FILE_NAME",
OracleType.VarChar, 500)).Value = _FileName;
ocm.Parameters.Add( new OracleParameter("FILE_BINARY",
OracleType.Blob)).Value = fileBinary;
//ocm.Parameters.Add( new OracleParameter("FILE_BINARY",
OracleType.Blob)).Value = ol;
ocm.Parameters.Add( new OracleParameter("p_err",
OracleType.Number)).Direction = ParameterDirection.Output;
ocm.ExecuteNonQuery();
tx.Commit();
oc.Close();
with the example provided in the documentation provided with
OracleClient.
The called stored procedure functions perfectly, I have tested it
manually with success, but when I try to use the function, I get the
error "Object must implement IConvertible".
I also tested with the code in comment, without success and the same
result. If anyone has an idea...
int fileLength = Convert.ToInt32(_BinaryFile.Length);
byte[] fileBinary = new byte[fileLength];
int status = _BinaryFile.Read(fileBinary, 0, fileLength);
_BinaryFile.Close();
OracleConnection oc = new
OracleConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
oc.Open();
OracleTransaction tx = oc.BeginTransaction();
OracleCommand ocm = oc.CreateCommand ();
ocm.Transaction = tx;
/*
ocm.CommandText = "declare xx blob; begin dbms_lob.createtemporary(xx,
false, 0); :tempblob := xx; end;";
ocm.Parameters.Add(new OracleParameter("tempblob",
OracleType.Blob)).Direction = ParameterDirection.Output;
ocm.ExecuteNonQuery();
OracleLob ol = (OracleLob)ocm.Parameters[0].Value;
ol.BeginBatch(OracleLobOpenMode.ReadWrite);
ol.Write(fileBinary, 0, fileLength);
ol.EndBatch();
*/
ocm.Parameters.Clear();
ocm.CommandText = PUT_FILE; //Constant
ocm.CommandType = CommandType.StoredProcedure;
ocm.Parameters.Add( new OracleParameter("PROCESS_ID",
OracleType.VarChar, 36)).Value = _ProcessID;
ocm.Parameters.Add( new OracleParameter("NSB", OracleType.VarChar,
15)).Value = _NSB;
ocm.Parameters.Add( new OracleParameter("GENERATION_DATE",
OracleType.DateTime)).Value = _Date;
if (_AllPublication)
ocm.Parameters.Add( new OracleParameter("ALLPUBLICATION",
OracleType.Number)).Value = 1;
else
ocm.Parameters.Add( new OracleParameter("ALLPUBLICATION",
OracleType.Number)).Value = 0;
ocm.Parameters.Add( new OracleParameter("FILTERED",
OracleType.Number)).Value = _Filtered;
ocm.Parameters.Add( new OracleParameter("DATE_FROM",
OracleType.DateTime)).Value = _DateFrom;
ocm.Parameters.Add( new OracleParameter("DATE_TO",
OracleType.DateTime)).Value = _DateTo;
ocm.Parameters.Add( new OracleParameter("FILE_FORMAT",
OracleType.VarChar, 3)).Value = _Format;
ocm.Parameters.Add( new OracleParameter("PATH", OracleType.VarChar,
500)).Value = _Path;
ocm.Parameters.Add( new OracleParameter("FILE_NAME",
OracleType.VarChar, 500)).Value = _FileName;
ocm.Parameters.Add( new OracleParameter("FILE_BINARY",
OracleType.Blob)).Value = fileBinary;
//ocm.Parameters.Add( new OracleParameter("FILE_BINARY",
OracleType.Blob)).Value = ol;
ocm.Parameters.Add( new OracleParameter("p_err",
OracleType.Number)).Direction = ParameterDirection.Output;
ocm.ExecuteNonQuery();
tx.Commit();
oc.Close();