[Mono-dev] Oracle LOB help
Leszek Ciesielski
skolima at gmail.com
Mon Oct 9 06:59:30 EDT 2006
On 10/8/06, Jorge Landrián Garcia <landrian at gmail.com> wrote:
> I read the post "[Mono-devel-list] System.Data.OracleClient and CLOB's", and
> I would like to ask you if exist a way in mono, to insert a lob without
> inserting first an empty_clob, the next code work in .NET but I can't make
> it work in mono
>
> OracleConnection conn = new
> OracleConnection("server=MyServer; integrated
> security=yes;");
> conn.Open();
> OracleTransaction tx = conn.BeginTransaction();
> OracleCommand cmd = conn.CreateCommand();
> cmd.Transaction = tx;
> cmd.CommandText = "declare xx blob; begin dbms_lob.createtemporary(xx,
> false, 0); :tempblob := xx; end;";
> cmd.Parameters.Add(new OracleParameter("tempblob",
> OracleType.Blob)).Direction = ParameterDirection.Output;
> cmd.ExecuteNonQuery();
> OracleLob tempLob = (OracleLob)cmd.Parameters[0].Value;
> tempLob.BeginBatch(OracleLobOpenMode.ReadWrite);
> tempLob.Write(tempbuff,0,tempbuff.Length);
> tempLob.EndBatch ();
> cmd.Parameters.Clear();
> cmd.CommandText = "myTable.myProc";
> cmd.CommandType = CommandType.StoredProcedure;
> cmd.Parameters.Add(new OracleParameter("ImportDoc", OracleType.Blob)).Value
> = tempLob;
> cmd.ExecuteNonQuery();
> tx.Commit();
>
> it is from MSDN.
>
> I realy appreciate any help from you.
>
> sorry because my english, I speak spanish.
Just for reference, the code is from
http://msdn2.microsoft.com/en-us/library/cydxhzhz.aspx , and MSDN guys
have a very bad habbit of not disposing IDisposable objects. I have
not tried it, but instead always used the double-shot approach (insert
empty [or create with a stored procedure], update).
More information about the Mono-devel-list
mailing list