// Construct by allocating a new handle as a child of the specified parent handle protected OciHandle( OciHandle parentOciHandle, OCI.HTYPE handleType ) { int rc; _parentOciHandle = parentOciHandle; _handleType = handleType; _unicode = parentOciHandle._unicode; if (_handleType < OCI.HTYPE.OCI_DTYPE_FIRST) { rc = TracedNativeMethods.OCIHandleAlloc( parentOciHandle, out _handle, _handleType, 0, ADP.NullHandleRef); } else { rc = TracedNativeMethods.OCIDescriptorAlloc( parentOciHandle, out _handle, _handleType, 0, ADP.NullHandleRef); } if (0 != rc || IntPtr.Zero == _handle) { throw ADP.OperationFailed("OCIDescriptorAllocate", rc); } // Console.WriteLine(String.Format("OracleClient: Allocate handle=0x{0,-8:x} parent=0x{2,-8:x} type={1}", _handle, _handleType, (null != parentOciHandle ) ? parentOciHandle.Handle : IntPtr.Zero)); }
protected OciHandle(OciHandle parentHandle, OCI.HTYPE handleType, OCI.MODE ocimode, HANDLEFLAG handleflags) : this() { RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { int num; this._handleType = handleType; this._parentHandle = parentHandle; this._refCount = 1; switch (handleType) { case OCI.HTYPE.OCI_DTYPE_TIMESTAMP: case OCI.HTYPE.OCI_DTYPE_TIMESTAMP_TZ: case OCI.HTYPE.OCI_DTYPE_TIMESTAMP_LTZ: case OCI.HTYPE.OCI_DTYPE_INTERVAL_DS: case OCI.HTYPE.OCI_DTYPE_FIRST: case OCI.HTYPE.OCI_DTYPE_ROWID: case OCI.HTYPE.OCI_DTYPE_FILE: num = TracedNativeMethods.OCIDescriptorAlloc(parentHandle.EnvironmentHandle, out this.handle, handleType); if ((num != 0) || (IntPtr.Zero == base.handle)) { throw System.Data.Common.ADP.OperationFailed("OCIDescriptorAlloc", num); } break; case OCI.HTYPE.OCI_HTYPE_ENV: if ((handleflags & HANDLEFLAG.NLS) != HANDLEFLAG.NLS) { num = TracedNativeMethods.OCIEnvCreate(out this.handle, ocimode); if ((num != 0) || (IntPtr.Zero == base.handle)) { throw System.Data.Common.ADP.OperationFailed("OCIEnvCreate", num); } } else { num = TracedNativeMethods.OCIEnvNlsCreate(out this.handle, ocimode, 0, 0); if ((num != 0) || (IntPtr.Zero == base.handle)) { throw System.Data.Common.ADP.OperationFailed("OCIEnvNlsCreate", num); } } break; case OCI.HTYPE.OCI_HTYPE_ERROR: case OCI.HTYPE.OCI_HTYPE_SVCCTX: case OCI.HTYPE.OCI_HTYPE_STMT: case OCI.HTYPE.OCI_HTYPE_SERVER: case OCI.HTYPE.OCI_HTYPE_SESSION: num = TracedNativeMethods.OCIHandleAlloc(parentHandle.EnvironmentHandle, out this.handle, handleType); if ((num != 0) || (IntPtr.Zero == base.handle)) { throw System.Data.Common.ADP.OperationFailed("OCIHandleAlloc", num); } break; } if (parentHandle != null) { parentHandle.AddRef(); this._isUnicode = parentHandle.IsUnicode; } else { this._isUnicode = (handleflags & HANDLEFLAG.UNICODE) == HANDLEFLAG.UNICODE; } } }