| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070 |
- //
- // 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
- {
- private static bool traceOci;
- #if TRACE
- 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)
- {
- Trace.WriteLineIf(traceOci, string.Format("OCIAttrSet ({0}, {1})", trghndltyp, attrtype), "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, string.Format("OCIAttrSetString ({0}, {1})", trghndltyp, attrtype), "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCIErrorGet", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCIBindByName", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCIBindByName", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCIBindByName", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCIBindByPos", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCIBindByPos", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCIBindByPos", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCIDefineByPos", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCIDefineByPosPtr", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, string.Format("OCIDescriptorFree ({0})", type), "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCIEnvCreate", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCIAttrGet", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCIAttrGetSByte", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCIAttrGetByte", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCIAttrGetUInt16", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCIAttrGetInt32", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCIAttrGetIntPtr", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCIDescriptorAlloc", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, string.Format("OCIHandleAlloc ({0})", type), "OCI");
- return OciNativeCalls.OCIHandleAlloc (parenth, out descpp, type, xtramem_sz, usrmempp);
- }
- internal static int OCIHandleFree (IntPtr hndlp,
- OciHandleType type)
- {
- Trace.WriteLineIf(traceOci, string.Format("OCIHandleFree ({0})", type), "OCI");
- return OciNativeCalls.OCIHandleFree (hndlp, type);
- }
- internal static int OCILobClose (IntPtr svchp,
- IntPtr errhp,
- IntPtr locp)
- {
- Trace.WriteLineIf(traceOci, "OCILobClose", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCILobCopy", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCILobErase", "OCI");
- return OciNativeCalls.OCILobErase (svchp, errhp, locp, ref amount, offset);
- }
- internal static int OCILobGetChunkSize (IntPtr svchp,
- IntPtr errhp,
- IntPtr locp,
- out uint chunk_size)
- {
- Trace.WriteLineIf(traceOci, "OCILobGetChunkSize", "OCI");
- return OciNativeCalls.OCILobGetChunkSize (svchp, errhp, locp, out chunk_size);
- }
- internal static int OCILobGetLength (IntPtr svchp,
- IntPtr errhp,
- IntPtr locp,
- out uint lenp)
- {
- Trace.WriteLineIf(traceOci, "OCILobGetLength", "OCI");
- return OciNativeCalls.OCILobGetLength (svchp, errhp, locp, out lenp);
- }
- internal static int OCILobOpen (IntPtr svchp,
- IntPtr errhp,
- IntPtr locp,
- byte mode)
- {
- Trace.WriteLineIf(traceOci, "OCILobOpen", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCILobRead", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCILobTrim", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCILobWrite", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCINlsGetInfo", "OCI");
- return OciNativeCalls.OCINlsGetInfo (hndl, errhp, bufp, buflen, item);
- }
- internal static int OCIServerAttach (IntPtr srvhp,
- IntPtr errhp,
- string dblink,
- int dblink_len,
- uint mode)
- {
- Trace.WriteLineIf(traceOci, "OCIServerAttach", "OCI");
- return OciNativeCalls.OCIServerAttach (srvhp, errhp, dblink, dblink_len, mode);
- }
- internal static int OCIServerDetach (IntPtr srvhp,
- IntPtr errhp,
- uint mode)
- {
- Trace.WriteLineIf(traceOci, "OCIServerDetach", "OCI");
- return OciNativeCalls.OCIServerDetach (srvhp, errhp, mode);
- }
- internal static int OCIServerVersion (IntPtr hndlp,
- IntPtr errhp,
- ref byte[] bufp,
- uint bufsz,
- OciHandleType hndltype)
- {
- Trace.WriteLineIf(traceOci, "OCIServerVersion", "OCI");
- return OciNativeCalls.OCIServerVersion (hndlp,
- errhp,
- bufp,
- bufsz,
- hndltype);
- }
- internal static int OCISessionBegin (IntPtr svchp,
- IntPtr errhp,
- IntPtr usrhp,
- OciCredentialType credt,
- OciSessionMode mode)
- {
- Trace.WriteLineIf(traceOci, "OCISessionBegin", "OCI");
- return OciNativeCalls.OCISessionBegin (svchp, errhp, usrhp, credt, mode);
- }
- internal static int OCISessionEnd (IntPtr svchp,
- IntPtr errhp,
- IntPtr usrhp,
- uint mode)
- {
- Trace.WriteLineIf(traceOci, "OCISessionEnd", "OCI");
- return OciNativeCalls.OCISessionEnd (svchp, errhp, usrhp, mode);
- }
- internal static int OCIParamGet (IntPtr hndlp,
- OciHandleType htype,
- IntPtr errhp,
- out IntPtr parmdpp,
- int pos)
- {
- Trace.WriteLineIf(traceOci, "OCIParamGet", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCIStmtExecute", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCIStmtFetch", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, string.Format("OCIStmtPrepare ({0})", System.Text.Encoding.UTF8.GetString(stmt)), "OCI");
- return OciNativeCalls.OCIStmtPrepare (stmthp, errhp, stmt, stmt_length, language, mode);
- }
- internal static int OCITransCommit (IntPtr svchp,
- IntPtr errhp,
- uint flags)
- {
- Trace.WriteLineIf(traceOci, "OCITransCommit", "OCI");
- return OciNativeCalls.OCITransCommit (svchp, errhp, flags);
- }
- internal static int OCITransRollback (IntPtr svchp,
- IntPtr errhp,
- uint flags)
- {
- Trace.WriteLineIf(traceOci, "OCITransRollback", "OCI");
- return OciNativeCalls.OCITransRollback (svchp, errhp, flags);
- }
- internal static int OCITransStart (IntPtr svchp,
- IntPtr errhp,
- uint timeout,
- OciTransactionFlags flags)
- {
- Trace.WriteLineIf(traceOci, "OCITransStart", "OCI");
- return OciNativeCalls.OCITransStart (svchp, errhp, timeout, flags);
- }
- internal static int OCICharSetToUnicode (
- IntPtr svchp,
- StringBuilder dst,
- byte [] src,
- out int rsize)
- {
- Trace.WriteLineIf(traceOci, "OCICharSetToUnicode", "OCI");
- 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)
- {
- Trace.WriteLineIf(traceOci, "OCICharSetToUnicode", "OCI");
- 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
- //http://download-uk.oracle.com/docs/cd/B14117_01/appdev.101/b10779/oci05bnd.htm#423147
- internal static IntPtr AllocateClear (int cb)
- {
- IntPtr result = Marshal.AllocHGlobal ( cb);
- for (int cleaner = 0; cleaner < cb; cleaner ++)
- Marshal.WriteByte (result, cleaner, 0);
- return result;
- }
- }
- }
|