static internal extern int OCISessionEnd ( HandleRef svchp, HandleRef errhp, HandleRef usrhp, OCI.MODE mode );
static internal extern int OCISessionBegin ( HandleRef svchp, HandleRef errhp, HandleRef usrhp, OCI.CRED credt, OCI.MODE mode );
static internal extern int OCIStmtFetch ( HandleRef stmtp, HandleRef errhp, int nrows, OCI.FETCH orientation, OCI.MODE mode );
static internal extern int OCIServerAttach ( HandleRef srvhp, HandleRef errhp, [In, MarshalAs(UnmanagedType.LPArray)] byte[] dblink, int dblink_len, OCI.MODE mode // Must always be OCI_DEFAULT );
static internal extern int OCIStmtPrepare ( HandleRef stmtp, HandleRef errhp, [In, MarshalAs(UnmanagedType.LPArray)] byte[] stmt, int stmt_len, OCI.SYNTAX language, OCI.MODE mode );
static internal extern int OCIStmtExecute ( HandleRef svchp, HandleRef stmtp, HandleRef errhp, int iters, int rowoff, HandleRef snap_in, HandleRef snap_out, OCI.MODE mode );
static internal extern int OCIEnvCreate ( out IntPtr envhpp, // can't return a handle ref! OCI.MODE mode, HandleRef ctxp, HandleRef malocfp, // pointer to malloc function HandleRef ralocfp, // pointer to realloc function HandleRef mfreefp, // pointer to free function int xtramemsz, HandleRef usrmempp );
internal static int OCISessionEnd(IntPtr svchp, IntPtr errhp, IntPtr usrhp, OCI.MODE mode) { if (Bid.AdvancedOn) { Bid.Trace("<oc.OCISessionEnd|ADV|OCI> svchp=0x%-07Ix errhp=0x%-07Ix usrhp=0x%-07Ix mode=0x%x{OCI.MODE}\n", svchp, errhp, usrhp, (int)mode); } int num = System.Data.Common.UnsafeNativeMethods.OCISessionEnd(svchp, errhp, usrhp, mode); if (Bid.AdvancedOn) { Bid.Trace("<oc.OCISessionEnd|ADV|OCI|RET> rc=%d\n", num); } return(num); }
internal static int OCIServerDetach(IntPtr srvhp, IntPtr errhp, OCI.MODE mode) { if (Bid.AdvancedOn) { Bid.Trace("<oc.OCIServerDetach|ADV|OCI> srvhp=0x%-07Ix errhp=0x%-07Ix mode=0x%x{OCI.MODE}\n", srvhp, errhp, (int)mode); } int num = System.Data.Common.UnsafeNativeMethods.OCIServerDetach(srvhp, errhp, mode); if (Bid.AdvancedOn) { Bid.Trace("<oc.OCIServerDetach|ADV|OCI|RET> rc=%d\n", num); } return(num); }
internal static int OCIEnvNlsCreate(out IntPtr envhpp, OCI.MODE mode, ushort charset, ushort ncharset) { if (Bid.AdvancedOn) { Bid.Trace("<oc.OCIEnvNlsCreate|ADV|OCI> mode=0x%x{OCI.MODE} ctxp=0x%-07Ix malocfp=0x%-07Ix ralocfp=0x%-07Ix mfreefp=0x%-07Ix xtramemsz=0x%-07Ix usrmempp=0x%-07Ix charset=%d ncharset=%d", (int)mode, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, charset, ncharset); } int num = System.Data.Common.UnsafeNativeMethods.OCIEnvNlsCreate(out envhpp, mode, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, charset, ncharset); if (Bid.AdvancedOn) { Bid.Trace("<oc.OCIEnvNlsCreate|ADV|OCI|RET> envhpp=0x%-07Ix rc=%d\n", envhpp, num); } return(num); }
static internal extern int OCIDefineByPos ( HandleRef stmtp, out IntPtr hndlpp, // can't return a handle ref! HandleRef errhp, int position, HandleRef valuep, int value_sz, OCI.DATATYPE dty, HandleRef indp, HandleRef rlenp, //ub2* HandleRef rcodep, //ub2* OCI.MODE mode );
internal static int OCITransRollback(OciHandle srvhp, OciHandle errhp, OCI.MODE mode) { if (Bid.AdvancedOn) { Bid.Trace("<oc.OCITransRollback|ADV|OCI> srvhp=0x%-07Ix errhp=0x%-07Ix mode=0x%x{OCI.MODE}\n", OciHandle.HandleValueToTrace(srvhp), OciHandle.HandleValueToTrace(errhp), (int)mode); } int num = System.Data.Common.UnsafeNativeMethods.OCITransRollback(srvhp, errhp, mode); if (Bid.AdvancedOn) { Bid.Trace("<oc.OCITransRollback|ADV|OCI|RET> rc=%d\n", num); } return(num); }
private static void Initialize() { lock (locked) { if (!isInitialized) { bool unicode = false; OCI.MODE environmentMode = OCI.MODE.OCI_DATA_AT_EXEC | OCI.MODE.OCI_BATCH_MODE; OCI.DetermineClientVersion(); environmentHandle = new OciEnvironmentHandle(environmentMode, unicode); availableErrorHandle = new OciErrorHandle(environmentHandle); isInitialized = true; } } }
static internal extern int OCIBindByName ( HandleRef stmtp, out IntPtr bindpp, // can't return a handle ref! HandleRef errhp, [In, MarshalAs(UnmanagedType.LPArray)] byte[] placeholder, int placeh_len, HandleRef valuep, int value_sz, OCI.DATATYPE dty, HandleRef indp, HandleRef alenp, //ub2* HandleRef rcodep, //ub2* int maxarr_len, HandleRef curelap, //ub4* OCI.MODE mode );
static void Initialize() { lock (locked) { if (!isInitialized) { bool unicode = false; IntPtr envhp; OCI.MODE environmentMode = (OCI.MODE.OCI_THREADED | OCI.MODE.OCI_OBJECT); // NOTE: cannot be NO_MUTEX because we might be multi-threaded. //1 TODO: we only use this environment handle in the OracleNumber class, //1 which doesn't have logic to determine whether we need Unicode or not; //1 we should modify OracleNumber to have that logic, but it's only for //1 consistency -- nothing will break #if NEVER if (OCI.ClientVersionAtLeastOracle9i) { unicode = true; environmentMode |= OCI.MODE.OCI_UTF16; } #endif //0 int rc = TracedNativeMethods.OCIEnvCreate( out envhp, // envhpp environmentMode, // mode ADP.NullHandleRef, // ctxp ADP.NullHandleRef, // malocfp ADP.NullHandleRef, // ralocfp ADP.NullHandleRef, // mfreefp 0, // xtramemsz ADP.NullHandleRef // usrmempp ); if (rc != 0 || envhp == IntPtr.Zero) { throw ADP.OperationFailed("OCIEnvCreate", rc); } environmentHandle = new OciEnvironmentHandle(envhp, unicode); availableErrorHandle = new OciErrorHandle(environmentHandle); isInitialized = true; } } }
internal void Bind( OciHandle statementHandle, NativeBuffer buffer, OciHandle errorHandle, int rowBufferLength ) { // Binds the buffer for the column to the statement handle specified. OciHandle defineHandle = null; IntPtr h; OCI.MODE mode = OCI.MODE.OCI_DEFAULT; int bindSize; OCI.DATATYPE ociType = _metaType.OciType; _rowBuffer = buffer; if (_metaType.IsLong) { mode = OCI.MODE.OCI_DYNAMIC_FETCH; bindSize = Int32.MaxValue; } else { bindSize = _size; } HandleRef indicatorLocation = ADP.NullHandleRef; HandleRef lengthLocation = ADP.NullHandleRef; HandleRef valueLocation = _rowBuffer.PtrOffset(_valueOffset); if (-1 != _indicatorOffset) { indicatorLocation = _rowBuffer.PtrOffset(_indicatorOffset); } if (-1 != _lengthOffset && !_metaType.IsLong) { lengthLocation = _rowBuffer.PtrOffset(_lengthOffset); } try { try { int rc = TracedNativeMethods.OCIDefineByPos( statementHandle, // hndlp out h, // defnpp errorHandle, // errhp _ordinal + 1, // position valueLocation, // valuep bindSize, // value_sz ociType, // htype indicatorLocation, // indp, lengthLocation, // rlenp, ADP.NullHandleRef, // rcodep, mode // mode ); if (rc != 0) { _connection.CheckError(errorHandle, rc); } defineHandle = new OciDefineHandle(statementHandle, h); if (0 != rowBufferLength) { int valOffset = rowBufferLength; int indOffset = (-1 != _indicatorOffset) ? rowBufferLength : 0; int lenOffset = (-1 != _lengthOffset && !_metaType.IsLong) ? rowBufferLength : 0; rc = TracedNativeMethods.OCIDefineArrayOfStruct( defineHandle, errorHandle, valOffset, indOffset, lenOffset, 0 // never use rcodep above... ); if (rc != 0) { _connection.CheckError(errorHandle, rc); } } if (!_connection.UnicodeEnabled) { if (_metaType.UsesNationalCharacterSet) { Debug.Assert(!_metaType.IsLong, "LONG data may never be bound as NCHAR"); // NOTE: the order is important here; setting charsetForm will // reset charsetId (I found this out the hard way...) defineHandle.SetAttribute(OCI.ATTR.OCI_ATTR_CHARSET_FORM, (int)OCI.CHARSETFORM.SQLCS_NCHAR, errorHandle); } if (_bindAsUCS2) { // NOTE: the order is important here; setting charsetForm will // reset charsetId (I found this out the hard way...) defineHandle.SetAttribute(OCI.ATTR.OCI_ATTR_CHARSET_ID, OCI.OCI_UCS2ID, errorHandle); } } if (_metaType.IsLong) { // Initialize the longBuffer in the rowBuffer to null Marshal.WriteIntPtr((IntPtr)_rowBuffer.PtrOffset(_valueOffset), IntPtr.Zero); if (null != _longBuffer) { _longBuffer.Dispose(); _longBuffer = null; } // We require MTxOCI8 to be in the path somewhere for us to handle LONG data if (!OCI.IsNewMtxOci8Installed) #if EVERETT { throw ADP.MustInstallNewMtxOciLONG(); } #else //!EVERETT { throw ADP.MustInstallNewMtxOci(); } #endif //!EVERETT _callback = new OCI.Callback.OCICallbackDefine(_callback_GetColumnPiecewise); rc = TracedNativeMethods.MTxOciDefineDynamic( defineHandle, // defnp errorHandle, // errhp ADP.NullHandleRef, // dvoid *octxp, _callback // OCICallbackDefine ocbfp ); if (rc != 0) { _connection.CheckError(errorHandle, rc); } } } finally { // We don't need this any longer, get rid of it. OciHandle.SafeDispose(ref defineHandle); } }
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; } } }
internal static extern int OCIDefineByPos(OciHandle stmtp, out IntPtr hndlpp, OciHandle errhp, uint position, IntPtr valuep, int value_sz, [In, MarshalAs(UnmanagedType.U2)] OCI.DATATYPE dty, IntPtr indp, IntPtr alenp, IntPtr rcodep, [In, MarshalAs(UnmanagedType.U4)] OCI.MODE mode);
static internal extern int OCIServerDetach ( HandleRef srvhp, HandleRef errhp, OCI.MODE mode );
internal static int OCIBindByName(OciHandle stmtp, out IntPtr bindpp, OciHandle errhp, string placeholder, int placeh_len, IntPtr valuep, int value_sz, OCI.DATATYPE dty, IntPtr indp, IntPtr alenp, OCI.MODE mode) { if (Bid.AdvancedOn) { Bid.Trace("<oc.OCIBindByName|ADV|OCI> stmtp=0x%-07Ix errhp=0x%-07Ix placeholder=%-20ls placeh_len=%-2d valuep=0x%-07Ix value_sz=%-4d dty=%d{OCI.DATATYPE} indp=0x%-07Ix *indp=%-3d alenp=0x%-07Ix *alenp=%-4d rcodep=0x%-07Ix maxarr_len=%-4d curelap=0x%-07Ix mode=0x%x{OCI.MODE}\n", OciHandle.HandleValueToTrace(stmtp), OciHandle.HandleValueToTrace(errhp), placeholder, placeh_len, valuep, value_sz, (int)dty, indp, (IntPtr.Zero == indp) ? 0 : Marshal.ReadInt16(indp), alenp, (IntPtr.Zero == alenp) ? 0 : Marshal.ReadInt16(alenp), IntPtr.Zero, 0, IntPtr.Zero, (int)mode); } byte[] bytes = stmtp.GetBytes(placeholder); int length = bytes.Length; int num = System.Data.Common.UnsafeNativeMethods.OCIBindByName(stmtp, out bindpp, errhp, bytes, length, valuep, value_sz, dty, indp, alenp, IntPtr.Zero, 0, IntPtr.Zero, mode); if (Bid.AdvancedOn) { Bid.Trace("<oc.OCIBindByName|ADV|OCI|RET> bindpp=0x%-07Ix rc=%d\n", bindpp, num); } return(num); }
internal static extern int OCIEnvNlsCreate(out IntPtr envhpp, [In, MarshalAs(UnmanagedType.U4)] OCI.MODE mode, IntPtr ctxp, IntPtr malocfp, IntPtr ralocfp, IntPtr mfreefp, IntPtr xtramemsz, IntPtr usrmempp, ushort charset, ushort ncharset);
static internal extern int OCITransRollback ( HandleRef svchp, HandleRef errhp, OCI.MODE mode );
internal static int OCIDefineByPos(OciHandle stmtp, out IntPtr hndlpp, OciHandle errhp, uint position, IntPtr valuep, int value_sz, OCI.DATATYPE dty, IntPtr indp, IntPtr rlenp, IntPtr rcodep, OCI.MODE mode) { int num = System.Data.Common.UnsafeNativeMethods.OCIDefineByPos(stmtp, out hndlpp, errhp, position, valuep, value_sz, dty, indp, rlenp, rcodep, mode); if (Bid.AdvancedOn) { Bid.Trace("<oc.OCIDefineByPos|ADV|OCI|RET> stmtp=0x%-07Ix errhp=0x%-07Ix position=%-2d valuep=0x%-07Ix value_sz=%-4d dty=%-3d %-14ls indp=0x%-07Ix rlenp=0x%-07Ix rcodep=0x%-07Ix mode=0x%x{OCI.MODE} hndlpp=0x%-07Ix rc=%d\n", stmtp, errhp, position, valuep, value_sz, (int)dty, dty, indp, rlenp, rcodep, (int)mode, hndlpp, num); } return(num); }
internal static int OCIServerAttach(OciHandle srvhp, OciHandle errhp, string dblink, int dblink_len, OCI.MODE mode) { if (Bid.AdvancedOn) { Bid.Trace("<oc.OCIServerAttach|ADV|OCI> srvhp=0x%-07Ix errhp=0x%-07Ix dblink='%ls' dblink_len=%d mode=0x%x{OCI.MODE}\n", srvhp, errhp, dblink, dblink_len, (int)mode); } byte[] bytes = srvhp.GetBytes(dblink); int length = bytes.Length; int num = System.Data.Common.UnsafeNativeMethods.OCIServerAttach(srvhp, errhp, bytes, length, mode); if (Bid.AdvancedOn) { Bid.Trace("<oc.OCIServerAttach|ADV|OCI|RET> rc=%d\n", num); } return(num); }
static internal extern int OCITransCommit ( HandleRef svchp, HandleRef errhp, OCI.MODE mode );
internal static int OCISessionBegin(OciHandle svchp, OciHandle errhp, OciHandle usrhp, OCI.CRED credt, OCI.MODE mode) { if (Bid.AdvancedOn) { Bid.Trace("<oc.OCISessionBegin|ADV|OCI> svchp=0x%-07Ix errhp=0x%-07Ix usrhp=0x%-07Ix credt=%ls mode=0x%x{OCI.MODE}\n", svchp, errhp, usrhp, credt, (int)mode); } int num = System.Data.Common.UnsafeNativeMethods.OCISessionBegin(svchp, errhp, usrhp, credt, mode); if (Bid.AdvancedOn) { Bid.Trace("<oc.OCISessionBegin|ADV|OCI|RET> rc=%d\n", num); } return(num); }
internal static int OCIStmtExecute(OciHandle svchp, OciHandle stmtp, OciHandle errhp, int iters, OCI.MODE mode) { if (Bid.AdvancedOn) { Bid.Trace("<oc.OCIStmtExecute|ADV|OCI> svchp=0x%-07Ix stmtp=0x%-07Ix errhp=0x%-07Ix iters=%d rowoff=%d snap_in=0x%-07Ix snap_out=0x%-07Ix mode=0x%x{OCI.MODE}\n", svchp, stmtp, errhp, iters, 0, IntPtr.Zero, IntPtr.Zero, (int)mode); } int num = System.Data.Common.UnsafeNativeMethods.OCIStmtExecute(svchp, stmtp, errhp, (uint)iters, 0, IntPtr.Zero, IntPtr.Zero, mode); if (Bid.AdvancedOn) { Bid.Trace("<oc.OCIStmtExecute|ADV|OCI|RET> rc=%d\n", num); } return(num); }
internal static int OCIStmtFetch(OciHandle stmtp, OciHandle errhp, int nrows, OCI.FETCH orientation, OCI.MODE mode) { if (Bid.AdvancedOn) { Bid.Trace("<oc.OCIStmtFetch|ADV|OCI> stmtp=0x%-07Ix errhp=0x%-07Ix nrows=%d orientation=%d{OCI.FETCH}, mode=0x%x{OCI.MODE}\n", stmtp, errhp, nrows, (int)orientation, (int)mode); } int num = System.Data.Common.UnsafeNativeMethods.OCIStmtFetch(stmtp, errhp, (uint)nrows, orientation, mode); if (Bid.AdvancedOn) { Bid.Trace("<oc.OCIStmtFetch|ADV|OCI|RET> rc=%d\n", num); } return(num); }
internal static int OCIStmtPrepare(OciHandle stmtp, OciHandle errhp, string stmt, OCI.SYNTAX language, OCI.MODE mode, OracleConnection connection) { if (Bid.AdvancedOn) { Bid.Trace("<oc.OCIStmtPrepare|ADV|OCI> stmtp=0x%-07Ix errhp=0x%-07Ix stmt_len=%d language=%d{OCI.SYNTAX} mode=0x%x{OCI.MODE}\n\t\t%ls\n\n", stmtp, errhp, stmt.Length, (int)language, (int)mode, stmt); } byte[] bytes = connection.GetBytes(stmt, false); uint length = (uint)bytes.Length; int num = System.Data.Common.UnsafeNativeMethods.OCIStmtPrepare(stmtp, errhp, bytes, length, language, mode); if (Bid.AdvancedOn) { Bid.Trace("<oc.OCIStmtPrepare|ADV|OCI|RET> rc=%d\n", num); } return(num); }
internal static extern int OCIBindByName(OciHandle stmtp, out IntPtr bindpp, OciHandle errhp, [In, MarshalAs(UnmanagedType.LPArray)] byte[] placeholder, int placeh_len, IntPtr valuep, int value_sz, [In, MarshalAs(UnmanagedType.U2)] OCI.DATATYPE dty, IntPtr indp, IntPtr alenp, IntPtr rcodep, uint maxarr_len, IntPtr curelap, [In, MarshalAs(UnmanagedType.U4)] OCI.MODE mode);