internal OracleLob(OracleLob lob) { this._lobLocator = lob._lobLocator.Clone(); this._lobType = lob._lobLocator.LobType; this._charsetForm = lob._charsetForm; this._currentPosition = lob._currentPosition; this._isTemporaryState = lob._isTemporaryState; }
// (internal) Construct from a buffer internal OracleLob(OciLobLocator lobLocator) { _lobLocator = lobLocator.Clone(); _lobType = _lobLocator.LobType; _charsetForm = (OracleType.NClob == _lobType) ? OCI.CHARSETFORM.SQLCS_NCHAR : OCI.CHARSETFORM.SQLCS_IMPLICIT; #if EXPOSELOBBUFFERING _bufferedRequested = false; #endif //EXPOSELOBBUFFERING }
public override void Write(byte[] buffer, int offset, int count) { this.AssertObjectNotDisposed(); this.AssertConnectionIsOpen(); if (count < 0) { throw System.Data.Common.ADP.MustBePositive("count"); } if (offset < 0) { throw System.Data.Common.ADP.MustBePositive("offset"); } if (buffer == null) { throw System.Data.Common.ADP.ArgumentNull("buffer"); } if (buffer.Length < (offset + count)) { throw System.Data.Common.ADP.BufferExceeded("count"); } this.AssertTransactionExists(); if (this.IsNull) { throw System.Data.Common.ADP.LobWriteInvalidOnNull(); } this.AssertAmountIsValid((long)offset, "offset"); this.AssertAmountIsValid((long)count, "count"); this.AssertPositionIsValid(); OCI.CHARSETFORM csfrm = this._charsetForm; ushort csid = this.IsCharacterLob ? ((ushort)0x3e8) : ((ushort)0); int amtp = this.AdjustOffsetToOracle(count); int rc = 0; if (amtp != 0) { GCHandle handle = new GCHandle(); try { handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); IntPtr bufp = new IntPtr(((long)handle.AddrOfPinnedObject()) + offset); rc = TracedNativeMethods.OCILobWrite(this.ServiceContextHandle, this.ErrorHandle, this.Descriptor, ref amtp, this.CurrentOraclePosition, bufp, (uint)count, 0, csid, csfrm); } finally { if (handle.IsAllocated) { handle.Free(); } } if (rc != 0) { this.Connection.CheckError(this.ErrorHandle, rc); } amtp = this.AdjustOracleToOffset(amtp); this._currentPosition += amtp; } }
// (internal) Construct from an existing Lob object (copy constructor) internal OracleLob(OracleLob lob) { this._lobLocator = lob._lobLocator.Clone(); this._lobType = lob._lobLocator.LobType; this._charsetForm = lob._charsetForm; this._currentPosition = lob._currentPosition; #if EXPOSELOBBUFFERING this._isCurrentlyBuffered = lob._isCurrentlyBuffered; this._bufferedRequested = lob._bufferedRequested; #endif //EXPOSELOBBUFFERING this._isTemporaryState = lob._isTemporaryState; }
internal OracleLob(OracleConnection connection, OracleType oracleType) { this._lobLocator = new OciLobLocator(connection, oracleType); this._lobType = oracleType; this._charsetForm = (OracleType.NClob == this._lobType) ? OCI.CHARSETFORM.SQLCS_NCHAR : OCI.CHARSETFORM.SQLCS_IMPLICIT; this._isTemporaryState = 1; OCI.LOB_TYPE lobtype = (OracleType.Blob == oracleType) ? OCI.LOB_TYPE.OCI_TEMP_BLOB : OCI.LOB_TYPE.OCI_TEMP_CLOB; int rc = TracedNativeMethods.OCILobCreateTemporary(connection.ServiceContextHandle, connection.ErrorHandle, this._lobLocator.Descriptor, 0, this._charsetForm, lobtype, 0, OCI.DURATION.OCI_DURATION_BEGIN); if (rc != 0) { connection.CheckError(this.ErrorHandle, rc); } }
static internal extern int OCILobRead ( HandleRef svchp, HandleRef errhp, HandleRef locp, ref int amtp, uint offset, IntPtr bufp, // using pinned memory, IntPtr is OK int bufl, HandleRef ctxp, HandleRef cbfp, [In, MarshalAs(UnmanagedType.U2)] short csid, [In, MarshalAs(UnmanagedType.U1)] OCI.CHARSETFORM csfrm );
internal static int OCILobWrite(OciHandle svchp, OciHandle errhp, OciHandle locp, ref int amtp, uint offset, IntPtr bufp, uint buflen, byte piece, ushort csid, OCI.CHARSETFORM csfrm) { uint num2 = (uint)amtp; if (Bid.AdvancedOn) { Bid.Trace("<oc.OCILobWrite|ADV|OCI> svchp=0x%-07Ix errhp=0x%-07Ix locp=0x%-07Ix amt=%d offset=%u bufp=0x%-07Ix buflen=%d piece=%d{Byte} ctxp=0x%-07Ix cbfp=0x%-07Ix csid=%d csfrm=%d{OCI.CHARSETFORM}\n", OciHandle.HandleValueToTrace(svchp), OciHandle.HandleValueToTrace(errhp), OciHandle.HandleValueToTrace(locp), amtp, offset, bufp, (int)buflen, piece, IntPtr.Zero, IntPtr.Zero, csid, (int)csfrm); } int num = System.Data.Common.UnsafeNativeMethods.OCILobWrite(svchp, errhp, locp, ref num2, offset, bufp, buflen, piece, IntPtr.Zero, IntPtr.Zero, csid, csfrm); amtp = (int)num2; if (Bid.AdvancedOn) { Bid.Trace("<oc.OCILobWrite|ADV|OCI|RET> amt=%d, rc=%d\n", amtp, num); } return(num); }
internal static int OCILobCreateTemporary(OciHandle svchp, OciHandle errhp, OciHandle locp, [In, MarshalAs(UnmanagedType.U2)] ushort csid, [In, MarshalAs(UnmanagedType.U1)] OCI.CHARSETFORM csfrm, [In, MarshalAs(UnmanagedType.U1)] OCI.LOB_TYPE lobtype, int cache, [In, MarshalAs(UnmanagedType.U2)] OCI.DURATION duration) { if (Bid.AdvancedOn) { Bid.Trace("<oc.OCILobCreateTemporary|ADV|OCI> svchp=0x%-07Ix errhp=0x%-07Ix locp=0x%-07Ix csid=%d csfrm=%d{OCI.CHARSETFORM} lobtype=%d{OCI.LOB_TYPE} cache=%d duration=%d{OCI.DURATION}\n", OciHandle.HandleValueToTrace(svchp), OciHandle.HandleValueToTrace(errhp), OciHandle.HandleValueToTrace(locp), csid, (int)csfrm, (int)lobtype, cache, (int)duration); } int num = System.Data.Common.UnsafeNativeMethods.OCILobCreateTemporary(svchp, errhp, locp, csid, csfrm, lobtype, cache, duration); if (Bid.AdvancedOn) { Bid.Trace("<oc.OCILobCreateTemporary|ADV|OCI|RET> rc=%d\n", num); } return(num); }
internal static extern int OCILobWrite(OciHandle svchp, OciHandle errhp, OciHandle locp, ref uint amtp, uint offset, IntPtr bufp, uint buflen, byte piece, IntPtr ctxp, IntPtr cbfp, ushort csid, [In, MarshalAs(UnmanagedType.U1)] OCI.CHARSETFORM csfrm);
internal static extern int OCILobCreateTemporary(OciHandle svchp, OciHandle errhp, OciHandle locp, ushort csid, [In, MarshalAs(UnmanagedType.U1)] OCI.CHARSETFORM csfrm, [In, MarshalAs(UnmanagedType.U1)] OCI.LOB_TYPE lobtype, int cache, [In, MarshalAs(UnmanagedType.U2)] OCI.DURATION duration);
internal OracleLob(OciLobLocator lobLocator) { this._lobLocator = lobLocator.Clone(); this._lobType = this._lobLocator.LobType; this._charsetForm = (OracleType.NClob == this._lobType) ? OCI.CHARSETFORM.SQLCS_NCHAR : OCI.CHARSETFORM.SQLCS_IMPLICIT; }
/// <include file='doc\OracleLob.uex' path='docs/doc[@for="OracleLob.Write"]/*' /> public override void Write( byte[] buffer, int offset, int count ) { AssertObjectNotDisposed(); AssertConnectionIsOpen(); if (count < 0) { throw ADP.MustBePositive("count"); } if (offset < 0) { throw ADP.MustBePositive("offset"); } if (null == buffer) { throw ADP.ArgumentNull("buffer"); } if ((long)buffer.Length < ((long)offset + (long)count)) { throw ADP.BufferExceeded(); } AssertTransactionExists(); if (IsNull) { throw ADP.LobWriteInvalidOnNull(); } AssertAmountIsValid(offset, "offset"); AssertAmountIsValid(count, "count"); AssertPositionIsValid(); OCI.CHARSETFORM charsetForm = _charsetForm; short charsetId = IsCharacterLob ? OCI.OCI_UCS2ID : (short)0; int amount = AdjustOffsetToOracle(count); int rc = 0; if (0 == amount) { return; } #if EXPOSELOBBUFFERING EnsureBuffering(_bufferedRequested); #endif //EXPOSELOBBUFFERING // We need to pin the buffer and get the address of the offset that // the user requested; Oracle doesn't allow us to specify an offset // into the buffer. GCHandle handle = new GCHandle(); try { try { handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); IntPtr bufferPtr = new IntPtr((long)handle.AddrOfPinnedObject() + offset); rc = TracedNativeMethods.OCILobWrite( ServiceContextHandle, ErrorHandle, Descriptor, ref amount, CurrentOraclePosition, bufferPtr, count, (byte)OCI.PIECE.OCI_ONE_PIECE, ADP.NullHandleRef, ADP.NullHandleRef, charsetId, charsetForm ); } finally { #if EXPOSELOBBUFFERING if (_isCurrentlyBuffered) { _bufferIsDirty = true; } #endif //EXPOSELOBBUFFERING if (handle.IsAllocated) { handle.Free(); // Unpin the buffer } } } catch // Prevent exception filters from running in our space { throw; } if (0 != rc) { Connection.CheckError(ErrorHandle, rc); } amount = AdjustOracleToOffset(amount); _currentPosition += amount; }
internal bool Describe(ref int offset, OracleConnection connection, OciErrorHandle errorHandle) { byte num; short num3; bool flag = false; bool flag2 = false; this._describeHandle.GetAttribute(OCI.ATTR.OCI_ATTR_SQLCODE, out this._columnName, errorHandle, this._connection); this._describeHandle.GetAttribute(OCI.ATTR.OCI_ATTR_OBJECT, out num3, errorHandle); this._describeHandle.GetAttribute(OCI.ATTR.OCI_ATTR_SESSION, out num, errorHandle); this._isNullable = 0 != num; OCI.DATATYPE ociType = (OCI.DATATYPE)num3; switch (ociType) { case OCI.DATATYPE.VARCHAR2: case OCI.DATATYPE.CHAR: { int num2; this._describeHandle.GetAttribute(OCI.ATTR.OCI_ATTR_FNCODE, out this._byteSize, errorHandle); this._describeHandle.GetAttribute(OCI.ATTR.OCI_ATTR_CHARSET_FORM, out num, errorHandle); OCI.CHARSETFORM charsetform = (OCI.CHARSETFORM)num; this._bindAsUTF16 = connection.ServerVersionAtLeastOracle8; if (connection.ServerVersionAtLeastOracle9i && OCI.ClientVersionAtLeastOracle9i) { this._describeHandle.GetAttribute(OCI.ATTR.OCI_ATTR_CHAR_SIZE, out num3, errorHandle); num2 = num3; } else { num2 = this._byteSize; } if (charsetform == OCI.CHARSETFORM.SQLCS_NCHAR) { this._metaType = MetaType.GetMetaTypeForType((OCI.DATATYPE.CHAR == ociType) ? System.Data.OracleClient.OracleType.NChar : System.Data.OracleClient.OracleType.NVarChar); } else { this._metaType = MetaType.GetMetaTypeForType((OCI.DATATYPE.CHAR == ociType) ? System.Data.OracleClient.OracleType.Char : System.Data.OracleClient.OracleType.VarChar); if (this._bindAsUTF16) { this._byteSize *= System.Data.Common.ADP.CharSize; } } this._byteSize = Math.Max(this._byteSize, num2 * System.Data.Common.ADP.CharSize); flag = true; break; } case OCI.DATATYPE.NUMBER: this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.Number); this._byteSize = this._metaType.BindSize; this._describeHandle.GetAttribute(OCI.ATTR.OCI_ATTR_ENV, out this._precision, errorHandle); this._describeHandle.GetAttribute(OCI.ATTR.OCI_ATTR_SERVER, out this._scale, errorHandle); break; case OCI.DATATYPE.LONG: this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.LongVarChar); this._byteSize = this._metaType.BindSize; flag = true; flag2 = true; this._bindAsUTF16 = connection.ServerVersionAtLeastOracle8; break; case OCI.DATATYPE.ROWID: case OCI.DATATYPE.ROWID_DESC: case OCI.DATATYPE.UROWID: this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.RowId); this._byteSize = this._metaType.BindSize; if (connection.UnicodeEnabled) { this._bindAsUTF16 = true; this._byteSize *= System.Data.Common.ADP.CharSize; } flag = true; break; case OCI.DATATYPE.DATE: this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.DateTime); this._byteSize = this._metaType.BindSize; flag = true; break; case OCI.DATATYPE.RAW: this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.Raw); this._describeHandle.GetAttribute(OCI.ATTR.OCI_ATTR_FNCODE, out this._byteSize, errorHandle); flag = true; break; case OCI.DATATYPE.LONGRAW: this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.LongRaw); this._byteSize = this._metaType.BindSize; flag = true; flag2 = true; break; case OCI.DATATYPE.CLOB: this._describeHandle.GetAttribute(OCI.ATTR.OCI_ATTR_CHARSET_FORM, out num, errorHandle); this._metaType = MetaType.GetMetaTypeForType((2 == num) ? System.Data.OracleClient.OracleType.NClob : System.Data.OracleClient.OracleType.Clob); this._byteSize = this._metaType.BindSize; flag2 = true; break; case OCI.DATATYPE.BLOB: this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.Blob); this._byteSize = this._metaType.BindSize; flag2 = true; break; case OCI.DATATYPE.BFILE: this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.BFile); this._byteSize = this._metaType.BindSize; flag2 = true; break; case OCI.DATATYPE.TIMESTAMP: this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.Timestamp); this._byteSize = this._metaType.BindSize; flag = true; break; case OCI.DATATYPE.TIMESTAMP_TZ: this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.TimestampWithTZ); this._byteSize = this._metaType.BindSize; flag = true; break; case OCI.DATATYPE.INTERVAL_YM: this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.IntervalYearToMonth); this._byteSize = this._metaType.BindSize; break; case OCI.DATATYPE.INTERVAL_DS: this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.IntervalDayToSecond); this._byteSize = this._metaType.BindSize; break; case OCI.DATATYPE.TIMESTAMP_LTZ: this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.TimestampLocal); this._byteSize = this._metaType.BindSize; flag = true; break; default: throw System.Data.Common.ADP.TypeNotSupported(ociType); } if (this._isNullable) { this._indicatorOffset = offset; offset += IntPtr.Size; } else { this._indicatorOffset = -1; } if (flag) { this._lengthOffset = offset; offset += IntPtr.Size; } else { this._lengthOffset = -1; } this._valueOffset = offset; if ((OCI.DATATYPE.LONG == ociType) || (OCI.DATATYPE.LONGRAW == ociType)) { offset += IntPtr.Size; } else { offset += this._byteSize; } offset = (offset + (IntPtr.Size - 1)) & ~(IntPtr.Size - 1); OciHandle.SafeDispose(ref this._describeHandle); return(flag2); }