public void SetDateTime (OciHandle handle, OciErrorHandle errorHandle, short year, byte month, byte day, byte hour, byte min, byte sec, uint fsec, string timezone) { // Get size of buffer ulong rsize = 0; UIntPtr rsizep = new UIntPtr (rsize); int status = OciCalls.OCIUnicodeToCharSet (handle, null, timezone, ref rsizep); // Fill buffer rsize = rsizep.ToUInt64 (); byte[] bytes = new byte[rsize]; if (status == 0 && rsize > 0) OciCalls.OCIUnicodeToCharSet (handle, bytes, timezone, ref rsizep); if (fsec > 0) fsec = fsec * 1000000; uint timezoneSize = (uint) bytes.Length; OciCalls.OCIDateTimeConstruct (handle, errorHandle, this.Handle, year, month, day, hour, min, sec, fsec, bytes, timezoneSize); //uint valid = 0; //int result = OciCalls.OCIDateTimeCheck (handle, // errorHandle, this.Handle, out valid); }
public static void ThrowExceptionIfError (OciHandle hwnd, int status) { if (status == 0) return; OciErrorInfo info = HandleError (hwnd, status); throw new OracleException (info.ErrorCode, info.ErrorMessage); }
public int GetYearToMonth (OciHandle handle, OciErrorHandle errorHandle) { int years = 0; int months = 0; OciCalls.OCIIntervalGetYearMonth (handle, errorHandle, out years, out months, this.handle); return ((years * 12) + months); }
public TimeSpan GetDayToSecond (OciHandle handle, OciErrorHandle errorHandle) { int days = 0; int hours = 0; int mins = 0; int secs = 0; int fsec = 0; int fs = 0; OciCalls.OCIIntervalGetDaySecond (handle, errorHandle, out days, out hours, out mins, out secs, out fsec, this.handle); if (fsec > 0) { int fseci = (int) fsec; fs = fseci / 1000000; } return new TimeSpan (days, hours, mins, secs, fs); }
public static OciErrorInfo HandleError (OciHandle hwnd, int status) { OciErrorInfo info; info.ErrorCode = status; info.ErrorMessage = OciGlue.ReturnCodeToString (status); if (status == OciGlue.OCI_ERROR || status == OciGlue.OCI_SUCCESS_WITH_INFO) { OciHandle h = hwnd; if (h == null) throw new Exception ("Internal driver error: handle is null."); ulong errbufSize = 4096; UIntPtr errbufSizep = new UIntPtr (errbufSize); IntPtr errbuf = OciCalls.AllocateClear ((int)errbufSize); OciCalls.OCIErrorGet (hwnd, 1, IntPtr.Zero, out info.ErrorCode, errbuf, (uint) errbufSize, OciHandleType.Error); byte[] bytea = new byte[errbufSize]; Marshal.Copy (errbuf, bytea, 0, (int)errbufSize); errbufSize = 0; // first call to OCICharSetToUnicode gets the size OciCalls.OCICharSetToUnicode (h, null, bytea, ref errbufSizep); errbufSize = errbufSizep.ToUInt64 (); StringBuilder str = new StringBuilder ((int)errbufSize); // second call to OCICharSetToUnicode gets the string OciCalls.OCICharSetToUnicode (h, str, bytea, ref errbufSizep); string errmsg = String.Empty; if (errbufSize > 0) { errmsg = str.ToString (); info.ErrorMessage = String.Copy (errmsg); } Marshal.FreeHGlobal (errbuf); } return info; }
public OciBindHandle (OciHandle parent) : base (OciHandleType.Bind, parent, IntPtr.Zero) { }
public OciDateTimeDescriptor (OciHandle parent, IntPtr newHandle) : base (OciHandleType.TimeStamp, parent, newHandle) { }
public OciHandle (OciHandleType type, OciHandle parent, IntPtr newHandle) { this.type = type; this.parent = parent; this.handle = newHandle; }
public OciLobLocator(OciHandle parent, IntPtr handle) : base(OciHandleType.LobLocator, parent, handle) { }
public OciStatementHandle (OciHandle parent, IntPtr handle) : base (OciHandleType.Statement, parent, handle) { moreResults = false; }
//OciCredentialType credentialType; #endregion // Fields #region Constructors public OciSessionHandle(OciHandle parent, IntPtr handle) : base(OciHandleType.Session, parent, handle) { }
//OciServiceHandle service; //OciDataType type; #endregion // Fields #region Constructors public OciParameterDescriptor (OciHandle parent, IntPtr handle) : base (OciHandleType.Parameter, parent, handle) { }
internal OciHandle(OciHandleType type, OciHandle parent, IntPtr newHandle) { this.type = type; this.parent = parent; this.handle = newHandle; }
internal OciRowIdDescriptor GetAttributeRowIdDescriptor(OciErrorHandle errorHandle, OciHandle env) { OciRowIdDescriptor descriptor = null; IntPtr outputPtr = IntPtr.Zero; int outSize = 16; int status = 0; OciAttributeType attrType = OciAttributeType.RowId; outputPtr = OciCalls.AllocateClear(outSize); uint siz = (uint)outSize; status = OCIAttrGetRowIdDesc(Handle, HandleType, outputPtr, ref siz, attrType, errorHandle); if (status != 0) { OciErrorInfo info = errorHandle.HandleError(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } if (outputPtr != IntPtr.Zero && siz > 0) { descriptor = (OciRowIdDescriptor)env.Allocate(OciHandleType.RowId); descriptor.SetHandle(outputPtr); } return(descriptor); }
public OciIntervalDescriptor (OciHandle parent, OciHandleType type, IntPtr newHandle) : base (type, parent, newHandle) { }
public OciBindHandle(OciHandle parent) : base(OciHandleType.Bind, parent, IntPtr.Zero) { }
public OciServerHandle (OciHandle parent, IntPtr newHandle) : base (OciHandleType.Server, parent, newHandle) { }
public OciErrorHandle(OciHandle parent, IntPtr newHandle) : base(OciHandleType.Error, parent, newHandle) { }
// Get NLS Info // // handle = OciEnvironmentHandle or OciSessionHandle // bufflen = Length of byte buffer to allocate to retrieve the NLS info // item = OciNlsServiceType enum value // // if unsure how much you need, use OciNlsServiceType.MAXBUFSZ internal string GetNlsInfo (OciHandle handle, uint bufflen, OciNlsServiceType item) { byte[] buffer = new Byte[bufflen]; OciCalls.OCINlsGetInfo (handle, ErrorHandle, ref buffer, bufflen, (ushort) item); // Get length of returned string ulong rsize = 0; UIntPtr rsizep = new UIntPtr (rsize); OciCalls.OCICharSetToUnicode (Environment, null, buffer, ref rsizep); // Get string rsize = rsizep.ToUInt64 (); StringBuilder ret = new StringBuilder ((int)rsize); OciCalls.OCICharSetToUnicode (Environment, ret, buffer, ref rsizep); return ret.ToString (); }
public OciDescriptorHandle (OciHandleType type, OciHandle parent, IntPtr newHandle) : base (type, parent, newHandle) { }
public OciTransactionHandle (OciHandle parent, IntPtr handle) : base (OciHandleType.Transaction, parent, handle) { }
public OciTransactionHandle(OciHandle parent, IntPtr handle) : base(OciHandleType.Transaction, parent, handle) { }
internal OciDefineHandle(OciHandle parent, IntPtr newHandle) : base(OciHandleType.Define, parent, newHandle) { }
public OciServerHandle(OciHandle parent, IntPtr newHandle) : base(OciHandleType.Server, parent, newHandle) { }
protected virtual void Dispose (bool disposing) { if (!disposed) { FreeHandle (); if (disposing) { parent = null; } disposed = true; } }
public DateTime GetDateTime (OciHandle handle, OciErrorHandle errorHandle) { short year = 0; byte month = 0; byte day = 0; byte hour = 0; byte min = 0; byte sec = 0; uint fsec = 0; int fs = 0; OciCalls.OCIDateTimeGetDate (handle, errorHandle, this.Handle, out year, out month, out day); OciCalls.OCIDateTimeGetTime (handle, errorHandle, this.Handle, out hour, out min, out sec, out fsec); // a TIMESTAMP can have up to 9 digits of millisecond but DateTime only // can be up to 999. if (fsec > 0) { int fseci = (int) fsec; fs = fseci / 1000000; } return new DateTime(year, month, day, hour, min, sec, fs); }
public OciRowIdDescriptor (OciHandle parent, IntPtr newHandle) : base (OciHandleType.RowId, parent, newHandle) { }
public OciErrorHandle (OciHandle parent, IntPtr newHandle) : base (OciHandleType.Error, parent, newHandle) { }
internal OciRowIdDescriptor GetAttributeRowIdDescriptor (OciErrorHandle errorHandle, OciHandle env) { OciRowIdDescriptor descriptor = null; IntPtr outputPtr = IntPtr.Zero; int outSize = 16; int status = 0; OciAttributeType attrType = OciAttributeType.RowId; outputPtr = OciCalls.AllocateClear (outSize); uint siz = (uint) outSize; status = OCIAttrGetRowIdDesc (Handle, HandleType, outputPtr, ref siz, attrType, errorHandle); if (status != 0) { OciErrorInfo info = errorHandle.HandleError (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } if (outputPtr != IntPtr.Zero && siz > 0) { descriptor = (OciRowIdDescriptor) env.Allocate(OciHandleType.RowId); descriptor.SetHandle (outputPtr); } return descriptor; }
//OciServiceHandle service; //OciDataType type; #endregion // Fields #region Constructors public OciParameterDescriptor(OciHandle parent, IntPtr handle) : base(OciHandleType.Parameter, parent, handle) { }
public static OciErrorInfo HandleError (OciHandle hand) { OciErrorInfo info; info.ErrorCode = 0; info.ErrorMessage = String.Empty; ulong errbufSize = 4096; UIntPtr errbufSizep = new UIntPtr (errbufSize); IntPtr errbuf = OciCalls.AllocateClear ((int)errbufSize); OciCalls.OCIErrorGet (hand, 1, IntPtr.Zero, out info.ErrorCode, errbuf, (uint) errbufSize, OciHandleType.Error); byte[] bytea = new byte[errbufSize]; Marshal.Copy (errbuf, bytea, 0, (int)errbufSize); errbufSize = 0; OciHandle h = hand.Parent; if (h == null) h = hand; if (h == null) throw new Exception ("Internal driver error: handle is null."); // first call to OCICharSetToUnicode gets the size OciCalls.OCICharSetToUnicode (h, null, bytea, ref errbufSizep); errbufSize = errbufSizep.ToUInt64 (); StringBuilder str = new StringBuilder ((int)errbufSize); // second call to OCICharSetToUnicode gets the string OciCalls.OCICharSetToUnicode (h, str, bytea, ref errbufSizep); string errmsg = String.Empty; if (errbufSize > 0) errmsg = str.ToString (); else errmsg = "Internal driver error. Could not retrieve error message."; info.ErrorMessage = String.Copy (errmsg); Marshal.FreeHGlobal (errbuf); return info; }
public OciDateTimeDescriptor(OciHandle parent, IntPtr newHandle) : base(OciHandleType.TimeStamp, parent, newHandle) { }
public OciRowIdDescriptor(OciHandle parent, IntPtr newHandle) : base(OciHandleType.RowId, parent, newHandle) { }
public OciLobLocator (OciHandle parent, IntPtr handle) : base (OciHandleType.LobLocator, parent, handle) { }
internal OciDefineHandle (OciHandle parent, IntPtr newHandle) : base (OciHandleType.Define, parent, newHandle) { }
public OciStatementHandle(OciHandle parent, IntPtr handle) : base(OciHandleType.Statement, parent, handle) { moreResults = false; }
//OciCredentialType credentialType; #endregion // Fields #region Constructors public OciSessionHandle (OciHandle parent, IntPtr handle) : base (OciHandleType.Session, parent, handle) { }
internal OciDescriptorHandle(OciHandleType type, OciHandle parent, IntPtr newHandle) : base(type, parent, newHandle) { }
public OciServiceHandle (OciHandle parent, IntPtr handle) : base (OciHandleType.Service, parent, handle) { }
public OciServiceHandle(OciHandle parent, IntPtr handle) : base(OciHandleType.Service, parent, handle) { }