| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177 |
- //
- // OciCalls.cs
- //
- // Part of the Mono class libraries at
- // mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
- //
- // Assembly: System.Data.OracleClient.dll
- // Namespace: System.Data.OracleClient.Oci
- //
- // Authors: Joerg Rosenkranz <[email protected]>
- // Daniel Morgan <[email protected]>
- //
- // Copyright (C) Joerg Rosenkranz, 2004
- // Copyright (C) Daniel Morgan, 2005
- //
- // Licensed under the MIT/X11 License.
- //
- using System;
- using System.Diagnostics;
- using System.Runtime.InteropServices;
- using System.Text;
- namespace System.Data.OracleClient.Oci
- {
- internal sealed class OciCalls
- {
- #if TRACE
- private static bool traceOci;
- static OciCalls()
- {
- string env = Environment.GetEnvironmentVariable("OCI_TRACE");
- traceOci = (env != null && env.Length > 0);
- }
- #endif
- private OciCalls ()
- {}
- #region OCI native calls
- private sealed class OciNativeCalls
- {
- private OciNativeCalls ()
- {}
- [DllImport ("oci", EntryPoint = "OCIAttrSet")]
- internal static extern int OCIAttrSet (IntPtr trgthndlp,
- [MarshalAs (UnmanagedType.U4)] OciHandleType trghndltyp,
- IntPtr attributep,
- uint size,
- [MarshalAs (UnmanagedType.U4)] OciAttributeType attrtype,
- IntPtr errhp);
- [DllImport ("oci", EntryPoint = "OCIAttrSet")]
- internal static extern int OCIAttrSetString (IntPtr trgthndlp,
- [MarshalAs (UnmanagedType.U4)] OciHandleType trghndltyp,
- string attributep,
- uint size,
- [MarshalAs (UnmanagedType.U4)] OciAttributeType attrtype,
- IntPtr errhp);
- [DllImport ("oci")]
- internal static extern int OCIErrorGet (IntPtr hndlp,
- uint recordno,
- IntPtr sqlstate,
- out int errcodep,
- IntPtr bufp,
- uint bufsize,
- [MarshalAs (UnmanagedType.U4)] OciHandleType type);
- [DllImport ("oci", EntryPoint = "OCIBindByName")]
- internal static extern int OCIBindByName (IntPtr stmtp,
- out IntPtr bindpp,
- IntPtr errhp,
- string placeholder,
- int placeh_len,
- IntPtr valuep,
- int value_sz,
- [MarshalAs (UnmanagedType.U2)] OciDataType dty,
- ref short indp,
- IntPtr alenp,
- IntPtr rcodep,
- uint maxarr_len,
- IntPtr curelp,
- uint mode);
- [DllImport ("oci", EntryPoint = "OCIBindByName")]
- internal static extern int OCIBindByNameRef (IntPtr stmtp,
- out IntPtr bindpp,
- IntPtr errhp,
- string placeholder,
- int placeh_len,
- ref IntPtr valuep,
- int value_sz,
- [MarshalAs (UnmanagedType.U2)] OciDataType dty,
- ref short indp,
- IntPtr alenp,
- IntPtr rcodep,
- uint maxarr_len,
- IntPtr curelp,
- uint mode);
- [DllImport ("oci", EntryPoint = "OCIBindByName")]
- internal static extern int OCIBindByNameBytes (IntPtr stmtp,
- out IntPtr bindpp,
- IntPtr errhp,
- string placeholder,
- int placeh_len,
- byte[] valuep,
- int value_sz,
- [MarshalAs (UnmanagedType.U2)] OciDataType dty,
- ref short indp,
- IntPtr alenp,
- IntPtr rcodep,
- uint maxarr_len,
- IntPtr curelp,
- uint mode);
- [DllImport ("oci", EntryPoint = "OCIBindByPos")]
- internal static extern int OCIBindByPos (IntPtr stmtp,
- out IntPtr bindpp,
- IntPtr errhp,
- uint position,
- IntPtr valuep,
- int value_sz,
- [MarshalAs (UnmanagedType.U2)] OciDataType dty,
- ref short indp,
- IntPtr alenp,
- IntPtr rcodep,
- uint maxarr_len,
- IntPtr curelp,
- uint mode);
- [DllImport ("oci", EntryPoint = "OCIBindByPos")]
- internal static extern int OCIBindByPosBytes (IntPtr stmtp,
- out IntPtr bindpp,
- IntPtr errhp,
- uint position,
- byte[] valuep,
- int value_sz,
- [MarshalAs (UnmanagedType.U2)] OciDataType dty,
- ref short indp,
- IntPtr alenp,
- IntPtr rcodep,
- uint maxarr_len,
- IntPtr curelp,
- uint mode);
- [DllImport ("oci", EntryPoint = "OCIBindByPos")]
- internal static extern int OCIBindByPosRef (IntPtr stmtp,
- out IntPtr bindpp,
- IntPtr errhp,
- uint position,
- ref IntPtr valuep,
- int value_sz,
- [MarshalAs (UnmanagedType.U2)] OciDataType dty,
- ref short indp,
- IntPtr alenp,
- IntPtr rcodep,
- uint maxarr_len,
- IntPtr curelp,
- uint mode);
- [DllImport ("oci")]
- internal static extern int OCIDateTimeFromText (IntPtr hndl,
- IntPtr errhp, [In][Out] byte[] date_str, uint dstr_length,
- [In][Out] byte[] fmt, uint fmt_length,
- [In][Out] byte[] lang_name, uint lang_length, IntPtr datetime);
- [DllImport ("oci")]
- internal static extern int OCIDefineByPos (IntPtr stmtp,
- out IntPtr defnpp,
- IntPtr errhp,
- [MarshalAs (UnmanagedType.U4)] int position,
- IntPtr valuep,
- int value_sz,
- [MarshalAs (UnmanagedType.U4)] OciDataType dty,
- ref short indp,
- ref short rlenp,
- IntPtr rcodep,
- uint mode);
- [DllImport ("oci", EntryPoint="OCIDefineByPos")]
- internal static extern int OCIDefineByPosPtr (IntPtr stmtp,
- out IntPtr defnpp,
- IntPtr errhp,
- [MarshalAs (UnmanagedType.U4)] int position,
- ref IntPtr valuep,
- int value_sz,
- [MarshalAs (UnmanagedType.U4)] OciDataType dty,
- ref short indp,
- ref short rlenp,
- IntPtr rcodep,
- uint mode);
- [DllImport ("oci")]
- internal static extern int OCIDescriptorFree (IntPtr hndlp,
- [MarshalAs (UnmanagedType.U4)] OciHandleType type);
- [DllImport ("oci")]
- internal static extern int OCIEnvCreate (out IntPtr envhpp,
- [MarshalAs (UnmanagedType.U4)] OciEnvironmentMode mode,
- IntPtr ctxp,
- IntPtr malocfp,
- IntPtr ralocfp,
- IntPtr mfreep,
- int xtramem_sz,
- IntPtr usrmempp);
- [DllImport ("oci")]
- internal static extern int OCIAttrGet (IntPtr trgthndlp,
- [MarshalAs (UnmanagedType.U4)] OciHandleType trghndltyp,
- out IntPtr attributep,
- out int sizep,
- [MarshalAs (UnmanagedType.U4)] OciAttributeType attrtype,
- IntPtr errhp);
- [DllImport ("oci", EntryPoint = "OCIAttrGet")]
- internal static extern int OCIAttrGetSByte (IntPtr trgthndlp,
- [MarshalAs (UnmanagedType.U4)] OciHandleType trghndltyp,
- out sbyte attributep,
- IntPtr sizep,
- [MarshalAs (UnmanagedType.U4)] OciAttributeType attrtype,
- IntPtr errhp);
- [DllImport ("oci", EntryPoint = "OCIAttrGet")]
- internal static extern int OCIAttrGetByte (IntPtr trgthndlp,
- [MarshalAs (UnmanagedType.U4)] OciHandleType trghndltyp,
- out byte attributep,
- IntPtr sizep,
- [MarshalAs (UnmanagedType.U4)] OciAttributeType attrtype,
- IntPtr errhp);
- [DllImport ("oci", EntryPoint = "OCIAttrGet")]
- internal static extern int OCIAttrGetUInt16 (IntPtr trgthndlp,
- [MarshalAs (UnmanagedType.U4)] OciHandleType trghndltyp,
- out ushort attributep,
- IntPtr sizep,
- [MarshalAs (UnmanagedType.U4)] OciAttributeType attrtype,
- IntPtr errhp);
- [DllImport ("oci", EntryPoint = "OCIAttrGet")]
- internal static extern int OCIAttrGetInt32 (IntPtr trgthndlp,
- [MarshalAs (UnmanagedType.U4)] OciHandleType trghndltyp,
- out int attributep,
- IntPtr sizep,
- [MarshalAs (UnmanagedType.U4)] OciAttributeType attrtype,
- IntPtr errhp);
- [DllImport ("oci", EntryPoint = "OCIAttrGet")]
- internal static extern int OCIAttrGetIntPtr (IntPtr trgthndlp,
- [MarshalAs (UnmanagedType.U4)] OciHandleType trghndltyp,
- out IntPtr attributep,
- IntPtr sizep,
- [MarshalAs (UnmanagedType.U4)] OciAttributeType attrtype,
- IntPtr errhp);
- [DllImport ("oci")]
- internal static extern int OCIDescriptorAlloc (IntPtr parenth,
- out IntPtr hndlpp,
- [MarshalAs (UnmanagedType.U4)] OciHandleType type,
- int xtramem_sz,
- IntPtr usrmempp);
- [DllImport ("oci")]
- internal static extern int OCIHandleAlloc (IntPtr parenth,
- out IntPtr descpp,
- [MarshalAs (UnmanagedType.U4)] OciHandleType type,
- int xtramem_sz,
- IntPtr usrmempp);
- [DllImport ("oci")]
- internal static extern int OCIHandleFree (IntPtr hndlp,
- [MarshalAs (UnmanagedType.U4)] OciHandleType type);
- [DllImport ("oci")]
- internal static extern int OCILobClose (IntPtr svchp,
- IntPtr errhp,
- IntPtr locp);
- [DllImport ("oci")]
- internal static extern int OCILobCopy (IntPtr svchp,
- IntPtr errhp,
- IntPtr dst_locp,
- IntPtr src_locp,
- uint amount,
- uint dst_offset,
- uint src_offset);
- [DllImport ("oci")]
- internal static extern int OCILobErase (IntPtr svchp,
- IntPtr errhp,
- IntPtr locp,
- ref uint amount,
- uint offset);
- [DllImport ("oci")]
- internal static extern int OCILobGetChunkSize (IntPtr svchp,
- IntPtr errhp,
- IntPtr locp,
- out uint chunk_size);
- [DllImport ("oci")]
- internal static extern int OCILobGetLength (IntPtr svchp,
- IntPtr errhp,
- IntPtr locp,
- out uint lenp);
- [DllImport ("oci")]
- internal static extern int OCILobOpen (IntPtr svchp,
- IntPtr errhp,
- IntPtr locp,
- byte mode);
- [DllImport ("oci")]
- internal static extern int OCILobRead (IntPtr svchp,
- IntPtr errhp,
- IntPtr locp,
- ref uint amtp,
- uint offset,
- byte[] bufp,
- uint bufl,
- IntPtr ctxp,
- IntPtr cbfp,
- ushort csid,
- byte csfrm);
- [DllImport ("oci")]
- internal static extern int OCILobTrim (IntPtr svchp,
- IntPtr errhp,
- IntPtr locp,
- uint newlen);
- [DllImport ("oci")]
- internal static extern int OCILobWrite (IntPtr svchp,
- IntPtr errhp,
- IntPtr locp,
- ref uint amtp,
- uint offset,
- byte[] bufp,
- uint bufl,
- byte piece,
- IntPtr ctxp,
- IntPtr cbfp,
- ushort csid,
- byte csfrm);
- [DllImport ("oci")]
- internal static extern int OCINlsGetInfo (IntPtr hndl,
- IntPtr errhp,
- [In][Out] byte[] bufp,
- uint buflen,
- ushort item);
- [DllImport ("oci")]
- internal static extern int OCIServerAttach (IntPtr srvhp,
- IntPtr errhp,
- string dblink,
- [MarshalAs (UnmanagedType.U4)] int dblink_len,
- uint mode);
- [DllImport ("oci")]
- internal static extern int OCIServerDetach (IntPtr srvhp,
- IntPtr errhp,
- uint mode);
- [DllImport ("oci")]
- internal static extern int OCIServerVersion (IntPtr hndlp,
- IntPtr errhp,
- [In][Out] byte[] bufp,
- uint bufsz,
- [MarshalAs (UnmanagedType.U4)] OciHandleType type);
- [DllImport ("oci")]
- internal static extern int OCISessionBegin (IntPtr svchp,
- IntPtr errhp,
- IntPtr usrhp,
- [MarshalAs (UnmanagedType.U4)] OciCredentialType credt,
- [MarshalAs (UnmanagedType.U4)] OciSessionMode mode);
- [DllImport ("oci")]
- internal static extern int OCISessionEnd (IntPtr svchp,
- IntPtr errhp,
- IntPtr usrhp,
- uint mode);
- [DllImport ("oci")]
- internal static extern int OCIParamGet (IntPtr hndlp,
- [MarshalAs (UnmanagedType.U4)] OciHandleType htype,
- IntPtr errhp,
- out IntPtr parmdpp,
- [MarshalAs (UnmanagedType.U4)] int pos);
- [DllImport ("oci")]
- internal static extern int OCIStmtExecute (IntPtr svchp,
- IntPtr stmthp,
- IntPtr errhp,
- [MarshalAs (UnmanagedType.U4)] uint iters,
- uint rowoff,
- IntPtr snap_in,
- IntPtr snap_out,
- [MarshalAs (UnmanagedType.U4)] OciExecuteMode mode);
- [DllImport ("oci")]
- internal static extern int OCIStmtFetch (IntPtr stmtp,
- IntPtr errhp,
- uint nrows,
- ushort orientation,
- uint mode);
- [DllImport ("oci")]
- internal static extern int OCIStmtPrepare (IntPtr stmthp,
- IntPtr errhp,
- byte [] stmt,
- [MarshalAs (UnmanagedType.U4)] int stmt_length,
- [MarshalAs (UnmanagedType.U4)] OciStatementLanguage language,
- [MarshalAs (UnmanagedType.U4)] OciStatementMode mode);
- [DllImport ("oci")]
- internal static extern int OCITransCommit (IntPtr svchp,
- IntPtr errhp,
- uint flags);
- [DllImport ("oci")]
- internal static extern int OCITransRollback (IntPtr svchp,
- IntPtr errhp,
- uint flags);
- [DllImport ("oci")]
- internal static extern int OCITransStart (IntPtr svchp,
- IntPtr errhp,
- uint timeout,
- [MarshalAs (UnmanagedType.U4)] OciTransactionFlags flags);
- [DllImport ("oci")]
- internal static extern int OCICharSetToUnicode (
- IntPtr svchp,
- [MarshalAs (UnmanagedType.LPWStr)] StringBuilder dst,
- [MarshalAs (UnmanagedType.U4)] int dstlen,
- byte [] src,
- [MarshalAs (UnmanagedType.U4)] int srclen,
- [MarshalAs (UnmanagedType.U4)] out int rsize);
- [DllImport ("oci")]
- internal static extern int OCIUnicodeToCharSet (
- IntPtr svchp,
- byte [] dst,
- [MarshalAs (UnmanagedType.U4)] int dstlen,
- [MarshalAs (UnmanagedType.LPWStr)] string src,
- [MarshalAs (UnmanagedType.U4)] int srclen,
- [MarshalAs (UnmanagedType.U4)] out int rsize);
- }
- #endregion
- #region OCI call wrappers
- internal static int OCIAttrSet (IntPtr trgthndlp,
- OciHandleType trghndltyp,
- IntPtr attributep,
- uint size,
- OciAttributeType attrtype,
- IntPtr errhp)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, string.Format("OCIAttrSet ({0}, {1})", trghndltyp, attrtype), "OCI");
- #endif
- return OciNativeCalls.OCIAttrSet (trgthndlp, trghndltyp, attributep, size, attrtype, errhp);
- }
- internal static int OCIAttrSetString (IntPtr trgthndlp,
- OciHandleType trghndltyp,
- string attributep,
- uint size,
- OciAttributeType attrtype,
- IntPtr errhp)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, string.Format("OCIAttrSetString ({0}, {1})", trghndltyp, attrtype), "OCI");
- #endif
- return OciNativeCalls.OCIAttrSetString (trgthndlp, trghndltyp, attributep, size, attrtype, errhp);
- }
- internal static int OCIErrorGet (IntPtr hndlp,
- uint recordno,
- IntPtr sqlstate,
- out int errcodep,
- IntPtr bufp,
- uint bufsize,
- OciHandleType type)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCIErrorGet", "OCI");
- #endif
- return OciNativeCalls.OCIErrorGet (hndlp, recordno, sqlstate, out errcodep, bufp, bufsize, type);
- }
- internal static int OCIBindByName (IntPtr stmtp,
- out IntPtr bindpp,
- IntPtr errhp,
- string placeholder,
- int placeh_len,
- IntPtr valuep,
- int value_sz,
- OciDataType dty,
- ref short indp,
- IntPtr alenp,
- IntPtr rcodep,
- uint maxarr_len,
- IntPtr curelp,
- uint mode)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCIBindByName", "OCI");
- #endif
- return OciNativeCalls.OCIBindByName (stmtp, out bindpp, errhp, placeholder, placeh_len, valuep,
- value_sz, dty, ref indp, alenp, rcodep, maxarr_len, curelp, mode);
- }
- internal static int OCIBindByNameRef (IntPtr stmtp,
- out IntPtr bindpp,
- IntPtr errhp,
- string placeholder,
- int placeh_len,
- ref IntPtr valuep,
- int value_sz,
- OciDataType dty,
- ref short indp,
- IntPtr alenp,
- IntPtr rcodep,
- uint maxarr_len,
- IntPtr curelp,
- uint mode)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCIBindByName", "OCI");
- #endif
- return OciNativeCalls.OCIBindByNameRef (stmtp, out bindpp, errhp, placeholder, placeh_len, ref valuep,
- value_sz, dty, ref indp, alenp, rcodep, maxarr_len, curelp, mode);
- }
- internal static int OCIBindByNameBytes (IntPtr stmtp,
- out IntPtr bindpp,
- IntPtr errhp,
- string placeholder,
- int placeh_len,
- byte[] valuep,
- int value_sz,
- [MarshalAs (UnmanagedType.U2)] OciDataType dty,
- ref short indp,
- IntPtr alenp,
- IntPtr rcodep,
- uint maxarr_len,
- IntPtr curelp,
- uint mode)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCIBindByName", "OCI");
- #endif
- return OciNativeCalls.OCIBindByNameBytes (stmtp, out bindpp, errhp, placeholder, placeh_len, valuep,
- value_sz, dty, ref indp, alenp, rcodep, maxarr_len, curelp, mode);
- }
- internal static int OCIBindByPos (IntPtr stmtp,
- out IntPtr bindpp,
- IntPtr errhp,
- uint position,
- IntPtr valuep,
- int value_sz,
- [MarshalAs (UnmanagedType.U2)] OciDataType dty,
- ref short indp,
- IntPtr alenp,
- IntPtr rcodep,
- uint maxarr_len,
- IntPtr curelp,
- uint mode)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCIBindByPos", "OCI");
- #endif
- return OciNativeCalls.OCIBindByPos (stmtp, out bindpp, errhp, position, valuep,
- value_sz, dty, ref indp, alenp, rcodep, maxarr_len, curelp, mode);
- }
- internal static int OCIBindByPosRef (IntPtr stmtp,
- out IntPtr bindpp,
- IntPtr errhp,
- uint position,
- ref IntPtr valuep,
- int value_sz,
- [MarshalAs (UnmanagedType.U2)] OciDataType dty,
- ref short indp,
- IntPtr alenp,
- IntPtr rcodep,
- uint maxarr_len,
- IntPtr curelp,
- uint mode)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCIBindByPos", "OCI");
- #endif
- return OciNativeCalls.OCIBindByPosRef (stmtp, out bindpp, errhp, position, ref valuep,
- value_sz, dty, ref indp, alenp, rcodep, maxarr_len, curelp, mode);
- }
- internal static int OCIBindByPosBytes (IntPtr stmtp,
- out IntPtr bindpp,
- IntPtr errhp,
- uint position,
- byte[] valuep,
- int value_sz,
- [MarshalAs (UnmanagedType.U2)] OciDataType dty,
- ref short indp,
- IntPtr alenp,
- IntPtr rcodep,
- uint maxarr_len,
- IntPtr curelp,
- uint mode)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCIBindByPos", "OCI");
- #endif
- return OciNativeCalls.OCIBindByPosBytes (stmtp, out bindpp, errhp, position, valuep,
- value_sz, dty, ref indp, alenp, rcodep, maxarr_len, curelp, mode);
- }
- [DllImport ("oci")]
- internal static extern void OCIDateTimeConstruct (IntPtr hndl,
- IntPtr err,
- IntPtr datetime,
- short year,
- byte month,
- byte day,
- byte hour,
- byte min,
- byte sec,
- uint fsec,
- byte[] timezone,
- uint timezone_length);
- [DllImport ("oci")]
- internal static extern void OCIDateTimeGetDate (IntPtr hndl,
- IntPtr err,
- IntPtr datetime,
- out short year,
- out byte month,
- out byte day);
- [DllImport ("oci")]
- internal static extern void OCIDateTimeGetTime (IntPtr hndl,
- IntPtr err,
- IntPtr datetime,
- out byte hour,
- out byte min,
- out byte sec,
- out uint fsec);
- internal static int OCIDefineByPos (IntPtr stmtp,
- out IntPtr defnpp,
- IntPtr errhp,
- int position,
- IntPtr valuep,
- int value_sz,
- OciDataType dty,
- ref short indp,
- ref short rlenp,
- IntPtr rcodep,
- uint mode)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCIDefineByPos", "OCI");
- #endif
- return OciNativeCalls.OCIDefineByPos (stmtp, out defnpp, errhp, position, valuep,
- value_sz, dty, ref indp, ref rlenp, rcodep, mode);
- }
- internal static int OCIDefineByPosPtr (IntPtr stmtp,
- out IntPtr defnpp,
- IntPtr errhp,
- int position,
- ref IntPtr valuep,
- int value_sz,
- OciDataType dty,
- ref short indp,
- ref short rlenp,
- IntPtr rcodep,
- uint mode)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCIDefineByPosPtr", "OCI");
- #endif
- return OciNativeCalls.OCIDefineByPosPtr (stmtp, out defnpp, errhp, position, ref valuep,
- value_sz, dty, ref indp, ref rlenp, rcodep, mode);
- }
- internal static int OCIDescriptorFree (IntPtr hndlp,
- OciHandleType type)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, string.Format("OCIDescriptorFree ({0})", type), "OCI");
- #endif
- return OciNativeCalls.OCIDescriptorFree (hndlp, type);
- }
- internal static int OCIEnvCreate (out IntPtr envhpp,
- OciEnvironmentMode mode,
- IntPtr ctxp,
- IntPtr malocfp,
- IntPtr ralocfp,
- IntPtr mfreep,
- int xtramem_sz,
- IntPtr usrmempp)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCIEnvCreate", "OCI");
- #endif
- return OciNativeCalls.OCIEnvCreate (out envhpp, mode, ctxp, malocfp, ralocfp, mfreep,
- xtramem_sz, usrmempp);
- }
- internal static int OCIAttrGet (IntPtr trgthndlp,
- OciHandleType trghndltyp,
- out IntPtr attributep,
- out int sizep,
- OciAttributeType attrtype,
- IntPtr errhp)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCIAttrGet", "OCI");
- #endif
- return OciNativeCalls.OCIAttrGet (trgthndlp, trghndltyp, out attributep, out sizep, attrtype, errhp);
- }
- internal static int OCIAttrGetSByte (IntPtr trgthndlp,
- OciHandleType trghndltyp,
- out sbyte attributep,
- IntPtr sizep,
- OciAttributeType attrtype,
- IntPtr errhp)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCIAttrGetSByte", "OCI");
- #endif
- return OciNativeCalls.OCIAttrGetSByte (trgthndlp, trghndltyp, out attributep, sizep, attrtype, errhp);
- }
- internal static int OCIAttrGetByte (IntPtr trgthndlp,
- OciHandleType trghndltyp,
- out byte attributep,
- IntPtr sizep,
- OciAttributeType attrtype,
- IntPtr errhp)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCIAttrGetByte", "OCI");
- #endif
- return OciNativeCalls.OCIAttrGetByte (trgthndlp, trghndltyp, out attributep, sizep, attrtype, errhp);
- }
- internal static int OCIAttrGetUInt16 (IntPtr trgthndlp,
- OciHandleType trghndltyp,
- out ushort attributep,
- IntPtr sizep,
- OciAttributeType attrtype,
- IntPtr errhp)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCIAttrGetUInt16", "OCI");
- #endif
- return OciNativeCalls.OCIAttrGetUInt16 (trgthndlp, trghndltyp, out attributep, sizep, attrtype, errhp);
- }
- internal static int OCIAttrGetInt32 (IntPtr trgthndlp,
- OciHandleType trghndltyp,
- out int attributep,
- IntPtr sizep,
- OciAttributeType attrtype,
- IntPtr errhp)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCIAttrGetInt32", "OCI");
- #endif
- return OciNativeCalls.OCIAttrGetInt32 (trgthndlp, trghndltyp, out attributep, sizep, attrtype, errhp);
- }
- internal static int OCIAttrGetIntPtr (IntPtr trgthndlp,
- OciHandleType trghndltyp,
- out IntPtr attributep,
- IntPtr sizep,
- OciAttributeType attrtype,
- IntPtr errhp)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCIAttrGetIntPtr", "OCI");
- #endif
- return OciNativeCalls.OCIAttrGetIntPtr (trgthndlp, trghndltyp, out attributep, sizep, attrtype, errhp);
- }
- internal static int OCIDescriptorAlloc (IntPtr parenth,
- out IntPtr hndlpp,
- OciHandleType type,
- int xtramem_sz,
- IntPtr usrmempp)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCIDescriptorAlloc", "OCI");
- #endif
- return OciNativeCalls.OCIDescriptorAlloc (parenth, out hndlpp, type, xtramem_sz, usrmempp);
- }
- internal static int OCIHandleAlloc (IntPtr parenth,
- out IntPtr descpp,
- OciHandleType type,
- int xtramem_sz,
- IntPtr usrmempp)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, string.Format("OCIHandleAlloc ({0})", type), "OCI");
- #endif
- return OciNativeCalls.OCIHandleAlloc (parenth, out descpp, type, xtramem_sz, usrmempp);
- }
- internal static int OCIHandleFree (IntPtr hndlp,
- OciHandleType type)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, string.Format("OCIHandleFree ({0})", type), "OCI");
- #endif
- return OciNativeCalls.OCIHandleFree (hndlp, type);
- }
- internal static int OCILobClose (IntPtr svchp,
- IntPtr errhp,
- IntPtr locp)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCILobClose", "OCI");
- #endif
- return OciNativeCalls.OCILobClose (svchp, errhp, locp);
- }
- internal static int OCILobCopy (IntPtr svchp,
- IntPtr errhp,
- IntPtr dst_locp,
- IntPtr src_locp,
- uint amount,
- uint dst_offset,
- uint src_offset)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCILobCopy", "OCI");
- #endif
- return OciNativeCalls.OCILobCopy (svchp, errhp, dst_locp, src_locp, amount, dst_offset, src_offset);
- }
- internal static int OCILobErase (IntPtr svchp,
- IntPtr errhp,
- IntPtr locp,
- ref uint amount,
- uint offset)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCILobErase", "OCI");
- #endif
- return OciNativeCalls.OCILobErase (svchp, errhp, locp, ref amount, offset);
- }
- internal static int OCILobGetChunkSize (IntPtr svchp,
- IntPtr errhp,
- IntPtr locp,
- out uint chunk_size)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCILobGetChunkSize", "OCI");
- #endif
- return OciNativeCalls.OCILobGetChunkSize (svchp, errhp, locp, out chunk_size);
- }
- internal static int OCILobGetLength (IntPtr svchp,
- IntPtr errhp,
- IntPtr locp,
- out uint lenp)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCILobGetLength", "OCI");
- #endif
- return OciNativeCalls.OCILobGetLength (svchp, errhp, locp, out lenp);
- }
- internal static int OCILobOpen (IntPtr svchp,
- IntPtr errhp,
- IntPtr locp,
- byte mode)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCILobOpen", "OCI");
- #endif
- return OciNativeCalls.OCILobOpen (svchp, errhp, locp, mode);
- }
- internal static int OCILobRead (IntPtr svchp,
- IntPtr errhp,
- IntPtr locp,
- ref uint amtp,
- uint offset,
- byte[] bufp,
- uint bufl,
- IntPtr ctxp,
- IntPtr cbfp,
- ushort csid,
- byte csfrm)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCILobRead", "OCI");
- #endif
- return OciNativeCalls.OCILobRead (svchp, errhp, locp, ref amtp, offset, bufp, bufl,
- ctxp, cbfp, csid, csfrm);
- }
- internal static int OCILobTrim (IntPtr svchp,
- IntPtr errhp,
- IntPtr locp,
- uint newlen)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCILobTrim", "OCI");
- #endif
- return OciNativeCalls.OCILobTrim (svchp, errhp, locp, newlen);
- }
- internal static int OCILobWrite (IntPtr svchp,
- IntPtr errhp,
- IntPtr locp,
- ref uint amtp,
- uint offset,
- byte[] bufp,
- uint bufl,
- byte piece,
- IntPtr ctxp,
- IntPtr cbfp,
- ushort csid,
- byte csfrm)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCILobWrite", "OCI");
- #endif
- return OciNativeCalls.OCILobWrite (svchp, errhp, locp, ref amtp, offset, bufp, bufl,
- piece, ctxp, cbfp, csid, csfrm);
- }
- internal static int OCINlsGetInfo (IntPtr hndl,
- IntPtr errhp,
- ref byte[] bufp,
- uint buflen,
- ushort item)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCINlsGetInfo", "OCI");
- #endif
- return OciNativeCalls.OCINlsGetInfo (hndl, errhp, bufp, buflen, item);
- }
- internal static int OCIServerAttach (IntPtr srvhp,
- IntPtr errhp,
- string dblink,
- int dblink_len,
- uint mode)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCIServerAttach", "OCI");
- #endif
- return OciNativeCalls.OCIServerAttach (srvhp, errhp, dblink, dblink_len, mode);
- }
- internal static int OCIServerDetach (IntPtr srvhp,
- IntPtr errhp,
- uint mode)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCIServerDetach", "OCI");
- #endif
- return OciNativeCalls.OCIServerDetach (srvhp, errhp, mode);
- }
- internal static int OCIServerVersion (IntPtr hndlp,
- IntPtr errhp,
- ref byte[] bufp,
- uint bufsz,
- OciHandleType hndltype)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCIServerVersion", "OCI");
- #endif
- return OciNativeCalls.OCIServerVersion (hndlp,
- errhp,
- bufp,
- bufsz,
- hndltype);
- }
- internal static int OCISessionBegin (IntPtr svchp,
- IntPtr errhp,
- IntPtr usrhp,
- OciCredentialType credt,
- OciSessionMode mode)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCISessionBegin", "OCI");
- #endif
- return OciNativeCalls.OCISessionBegin (svchp, errhp, usrhp, credt, mode);
- }
- internal static int OCISessionEnd (IntPtr svchp,
- IntPtr errhp,
- IntPtr usrhp,
- uint mode)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCISessionEnd", "OCI");
- #endif
- return OciNativeCalls.OCISessionEnd (svchp, errhp, usrhp, mode);
- }
- internal static int OCIParamGet (IntPtr hndlp,
- OciHandleType htype,
- IntPtr errhp,
- out IntPtr parmdpp,
- int pos)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCIParamGet", "OCI");
- #endif
- return OciNativeCalls.OCIParamGet (hndlp, htype, errhp, out parmdpp, pos);
- }
- internal static int OCIStmtExecute (IntPtr svchp,
- IntPtr stmthp,
- IntPtr errhp,
- bool iters,
- uint rowoff,
- IntPtr snap_in,
- IntPtr snap_out,
- OciExecuteMode mode)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCIStmtExecute", "OCI");
- #endif
- uint it = 0;
- if (iters == true)
- it = 1;
- return OciNativeCalls.OCIStmtExecute (svchp, stmthp, errhp, it, rowoff,
- snap_in, snap_out, mode);
- }
- internal static int OCIStmtFetch (IntPtr stmtp,
- IntPtr errhp,
- uint nrows,
- ushort orientation,
- uint mode)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCIStmtFetch", "OCI");
- #endif
- return OciNativeCalls.OCIStmtFetch (stmtp, errhp, nrows, orientation, mode);
- }
- internal static int OCIStmtPrepare (IntPtr stmthp,
- IntPtr errhp,
- byte [] stmt,
- int stmt_length,
- OciStatementLanguage language,
- OciStatementMode mode)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, string.Format("OCIStmtPrepare ({0})", System.Text.Encoding.UTF8.GetString(stmt)), "OCI");
- #endif
- return OciNativeCalls.OCIStmtPrepare (stmthp, errhp, stmt, stmt_length, language, mode);
- }
- internal static int OCITransCommit (IntPtr svchp,
- IntPtr errhp,
- uint flags)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCITransCommit", "OCI");
- #endif
- return OciNativeCalls.OCITransCommit (svchp, errhp, flags);
- }
- internal static int OCITransRollback (IntPtr svchp,
- IntPtr errhp,
- uint flags)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCITransRollback", "OCI");
- #endif
- return OciNativeCalls.OCITransRollback (svchp, errhp, flags);
- }
- internal static int OCITransStart (IntPtr svchp,
- IntPtr errhp,
- uint timeout,
- OciTransactionFlags flags)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCITransStart", "OCI");
- #endif
- return OciNativeCalls.OCITransStart (svchp, errhp, timeout, flags);
- }
- internal static int OCICharSetToUnicode (
- IntPtr svchp,
- StringBuilder dst,
- byte [] src,
- out int rsize)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCICharSetToUnicode", "OCI");
- #endif
- return OciNativeCalls.OCICharSetToUnicode (svchp, dst, dst!=null ? dst.Capacity : 0, src, src.Length, out rsize);
- }
- internal static int OCIUnicodeToCharSet (
- IntPtr svchp,
- byte [] dst,
- [MarshalAs (UnmanagedType.LPWStr)] string src,
- [MarshalAs (UnmanagedType.U4)] out int rsize)
- {
- #if TRACE
- Trace.WriteLineIf(traceOci, "OCICharSetToUnicode", "OCI");
- #endif
- return OciNativeCalls.OCIUnicodeToCharSet (svchp, dst, dst!=null ? dst.Length : 0, src, src.Length, out rsize);
- }
- [DllImport ("oci")]
- internal static extern int OCIDateTimeCheck (IntPtr hndl,
- IntPtr err, IntPtr date, out uint valid);
- #endregion
- #region AllocateClear
- private static bool IsUnix =
- (int) Environment.OSVersion.Platform == 4 || (int) Environment.OSVersion.Platform == 128 || (int) Environment.OSVersion.Platform == 6;
- [DllImport("libc")]
- private static extern IntPtr calloc (int nmemb, int size);
- private const int GMEM_ZEROINIT = 0x40;
- [DllImport("kernel32")]
- private static extern IntPtr GlobalAlloc (int flags, int bytes);
- //http://download-uk.oracle.com/docs/cd/B14117_01/appdev.101/b10779/oci05bnd.htm#423147
- internal static IntPtr AllocateClear (int cb)
- {
- if (IsUnix) {
- return calloc (1, cb);
- } else {
- return GlobalAlloc (GMEM_ZEROINIT, cb);
- }
- }
- #endregion AllocateClear
- }
- }
|