private OracleLob CreateTemporaryLobForValue(OracleConnection connection, OracleType oracleType, object value)
        {
            switch (oracleType)
            {
            case OracleType.BFile:
                oracleType = OracleType.Blob;
                break;

            case OracleType.Blob:
            case OracleType.Clob:
            case OracleType.NClob:
                break;

            default:
                throw System.Data.Common.ADP.InvalidLobType(oracleType);
            }
            OracleLob stream = new OracleLob(connection, oracleType);

            byte[] buffer = value as byte[];
            if (buffer != null)
            {
                stream.Write(buffer, 0, buffer.Length);
                return(stream);
            }
            Encoding encoding = new UnicodeEncoding(false, false);

            stream.Seek(0L, SeekOrigin.Begin);
            StreamWriter writer = new StreamWriter(stream, encoding);

            writer.Write(value);
            writer.Flush();
            return(stream);
        }
Esempio n. 2
0
        public void SetBinaryData(int id, string fieldName, byte[] data)
        {
            string query = "select " + fieldName +
                           " from PUBLISH_HISTORY " +
                           " where ID  = " + id + " FOR UPDATE";

            using (DBCommandWrapper wrapper = GetSqlStringCommandWrapper(query))
            {
                using (System.Data.IDataReader reader = this.ExecuteReader(wrapper))
                {
                    if (reader.Read())
                    {
                        System.Data.OracleClient.OracleLob clob = ((OracleDataReaderWrapper)reader).InnerReader.GetOracleLob(0);
                        clob.Erase();
                        clob.Write(data, 0, data.Length);
                    }
                }
            }
        }
        private OracleLob CreateTemporaryLobForValue(OracleConnection connection, OracleType oracleType, object value)
        {
            switch (oracleType)
            {
                case OracleType.BFile:
                    oracleType = OracleType.Blob;
                    break;

                case OracleType.Blob:
                case OracleType.Clob:
                case OracleType.NClob:
                    break;

                default:
                    throw System.Data.Common.ADP.InvalidLobType(oracleType);
            }
            OracleLob stream = new OracleLob(connection, oracleType);
            byte[] buffer = value as byte[];
            if (buffer != null)
            {
                stream.Write(buffer, 0, buffer.Length);
                return stream;
            }
            Encoding encoding = new UnicodeEncoding(false, false);
            stream.Seek(0L, SeekOrigin.Begin);
            StreamWriter writer = new StreamWriter(stream, encoding);
            writer.Write(value);
            writer.Flush();
            return stream;
        }