public void InsertCLOB(string SQLStatement, string str)
 {
     if (SQLStatement.Length > 0)
     {
         if (connOracle.State.ToString().Equals("Open"))
         {
             byte[] newvalue = System.Text.Encoding.Unicode.GetBytes(str);
             sqlCommandOracle =
                 new System.Data.OracleClient.OracleCommand(SQLStatement, connOracle);
             rstOracle = sqlCommandOracle.ExecuteReader();
             rstOracle.Read();
             txn  = connOracle.BeginTransaction();
             clob = rstOracle.GetOracleLob(0);
             clob.Write(newvalue, 0, newvalue.Length);
             txn.Commit();
         }
     }
 }
Exemple #2
0
        // https://social.msdn.microsoft.com/Forums/en-US/dc1b053d-f0d5-48f8-ad82-fb6d96d27f80/how-to-insert-or-update-blob-data-for-sqlserver-based-on-buffersize?forum=adodotnetdataproviders
        public void WriteLargeFileChunckedOracle(string path)
        {
            byte[] buffer = new byte[1024];
            using (System.Data.OracleClient.OracleCommand cmd = null)
            {
                using (System.Data.OracleClient.OracleDataReader dataReader = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                {
                    // this code segment works well for Oracle database
                    System.Data.OracleClient.OracleLob lob = dataReader.GetOracleLob(1);
                    using (System.IO.Stream fileStream = System.IO.File.OpenRead(path))
                    {
                        lob.SetLength(0);

                        int readBytes = 0;
                        while ((readBytes = fileStream.Read(buffer, 0, buffer.Length)) > 0)
                        {
                            lob.Write(buffer, 0, readBytes);
                        } // Whend
                    }     // End Using fileStream
                }         // End Using dataReader
            }             // End Using cmd
        }                 // End Sub WriteLargeFileChunckedOracle