Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Since you could not find an example of creating a temporary lob pointer, here is an example in C# using the Microsoft Enterprise Library from a previous project. This example interfaces with a stored procedure, but is the same approach when using a SQL update and BLOB/CLOB:</p> <pre><code>internal static void Save(Attachments attachment) { try { // Microsoft Enterprise Library does not provide support for Oracle BLOB objects // The Microsoft Data Provider for Oracle needs to allocate a BLOB pointer in memory first // while running in the context of a database transaction. Once the placeholder is allocated, // the byte stream is written to the handler and then passed to Oracle to update the database // OracleConnection connection = new OracleConnection(System.Configuration.ConfigurationManager.ConnectionStrings["connstring_devl"].ConnectionString); connection.Open(); OracleTransaction transaction = connection.BeginTransaction(); OracleCommand command = connection.CreateCommand(); command.Transaction = transaction; command.CommandText = "declare xx blob; begin dbms_lob.createtemporary(xx, false, 0); :tempblob := xx; end;"; command.Parameters.Add(new OracleParameter("tempblob", OracleType.Blob)).Direction = ParameterDirection.Output; command.ExecuteNonQuery(); OracleLob tempLob = (OracleLob)command.Parameters[0].Value; tempLob.BeginBatch(OracleLobOpenMode.ReadWrite); if (attachment.FileContent != null) tempLob.Write(attachment.FileContent, 0, attachment.FileContent.Length); tempLob.EndBatch(); command.Parameters.Clear(); command.CommandText = MC_SAVE_ATTACHMENT; command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new OracleParameter("IN_USER_ID", OracleType.VarChar)).Value = attachment.UserID; command.Parameters.Add(new OracleParameter("IN_FILE_CONTENT", OracleType.Blob)).Value = tempLob; command.Parameters.Add(new OracleParameter("ERROR_DESC", OracleType.VarChar, 4000)).Direction = ParameterDirection.Output; command.ExecuteNonQuery(); transaction.Commit(); //Check errors and handle it (log, throw exception etc) errors = command.Parameters["error_desc"].Value.ToString(); HandleExceptions.CheckError(errors); } catch (Exception e) { string errMsg = e.Message; throw; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload