Ejemplo n.º 1
0
		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);
		}
Ejemplo n.º 2
0
		public static void ThrowExceptionIfError (OciHandle hwnd, int status)
		{
			if (status == 0)
				return;
			OciErrorInfo info = HandleError (hwnd, status);
			throw new OracleException (info.ErrorCode, info.ErrorMessage);
		}
Ejemplo n.º 3
0
		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);
		}
Ejemplo n.º 4
0
		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);                             
		}
Ejemplo n.º 5
0
		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;
		}
Ejemplo n.º 6
0
		public OciBindHandle (OciHandle parent)
			: base (OciHandleType.Bind, parent, IntPtr.Zero)
		{
		}
Ejemplo n.º 7
0
		public OciDateTimeDescriptor (OciHandle parent, IntPtr newHandle)
			: base (OciHandleType.TimeStamp, parent, newHandle)
		{
		}
Ejemplo n.º 8
0
		public OciHandle (OciHandleType type, OciHandle parent, IntPtr newHandle) {
			this.type = type;
			this.parent = parent;
			this.handle = newHandle;
		}
Ejemplo n.º 9
0
 public OciLobLocator(OciHandle parent, IntPtr handle)
     : base(OciHandleType.LobLocator, parent, handle)
 {
 }
Ejemplo n.º 10
0
		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)
        {
        }
Ejemplo n.º 12
0
		//OciServiceHandle service;
		//OciDataType type;

		#endregion // Fields

		#region Constructors

		public OciParameterDescriptor (OciHandle parent, IntPtr handle)
			: base (OciHandleType.Parameter, parent, handle)
		{
		}
Ejemplo n.º 13
0
 internal OciHandle(OciHandleType type, OciHandle parent, IntPtr newHandle)
 {
     this.type   = type;
     this.parent = parent;
     this.handle = newHandle;
 }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
		public OciIntervalDescriptor (OciHandle parent, OciHandleType type, IntPtr newHandle)
			: base (type, parent, newHandle)
		{
		}
Ejemplo n.º 16
0
 public OciBindHandle(OciHandle parent)
     : base(OciHandleType.Bind, parent, IntPtr.Zero)
 {
 }
Ejemplo n.º 17
0
		public OciServerHandle (OciHandle parent, IntPtr newHandle)
			: base (OciHandleType.Server, parent, newHandle)
		{
		}
 public OciErrorHandle(OciHandle parent, IntPtr newHandle)
     : base(OciHandleType.Error, parent, newHandle)
 {
 }
Ejemplo n.º 19
0
		// 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)
		{
		}
Ejemplo n.º 21
0
		public OciTransactionHandle (OciHandle parent, IntPtr handle)
			: base (OciHandleType.Transaction, parent, handle)
		{
		}
Ejemplo n.º 22
0
 public OciTransactionHandle(OciHandle parent, IntPtr handle)
     : base(OciHandleType.Transaction, parent, handle)
 {
 }
Ejemplo n.º 23
0
 internal OciDefineHandle(OciHandle parent, IntPtr newHandle)
     : base(OciHandleType.Define, parent, newHandle)
 {
 }
Ejemplo n.º 24
0
 public OciServerHandle(OciHandle parent, IntPtr newHandle)
     : base(OciHandleType.Server, parent, newHandle)
 {
 }
Ejemplo n.º 25
0
		protected virtual void Dispose (bool disposing) {
			if (!disposed) {
				FreeHandle ();
				if (disposing) {
					parent = null;
				}
				disposed = true;
			}
		}
Ejemplo n.º 26
0
		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);
		}
Ejemplo n.º 27
0
		public OciRowIdDescriptor (OciHandle parent, IntPtr newHandle)
			: base (OciHandleType.RowId, parent, newHandle)
		{
		}
Ejemplo n.º 28
0
		public OciErrorHandle (OciHandle parent, IntPtr newHandle)
			: base (OciHandleType.Error, parent, newHandle)
		{
		}
Ejemplo n.º 29
0
		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;
		}
Ejemplo n.º 30
0
        //OciServiceHandle service;
        //OciDataType type;

        #endregion         // Fields

        #region Constructors

        public OciParameterDescriptor(OciHandle parent, IntPtr handle)
            : base(OciHandleType.Parameter, parent, handle)
        {
        }
Ejemplo n.º 31
0
		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;
		}
Ejemplo n.º 32
0
 public OciDateTimeDescriptor(OciHandle parent, IntPtr newHandle)
     : base(OciHandleType.TimeStamp, parent, newHandle)
 {
 }
Ejemplo n.º 33
0
 public OciRowIdDescriptor(OciHandle parent, IntPtr newHandle)
     : base(OciHandleType.RowId, parent, newHandle)
 {
 }
Ejemplo n.º 34
0
		public OciLobLocator (OciHandle parent, IntPtr handle)
			: base (OciHandleType.LobLocator, parent, handle)
		{
		}
Ejemplo n.º 35
0
		internal OciDefineHandle (OciHandle parent, IntPtr newHandle)
			: base (OciHandleType.Define, parent, newHandle)
		{
		}
 public OciStatementHandle(OciHandle parent, IntPtr handle)
     : base(OciHandleType.Statement, parent, handle)
 {
     moreResults = false;
 }
Ejemplo n.º 37
0
		//OciCredentialType credentialType;

		#endregion // Fields

		#region Constructors

		public OciSessionHandle (OciHandle parent, IntPtr handle)
			: base (OciHandleType.Session, parent, handle)
		{
		}
Ejemplo n.º 38
0
 internal OciDescriptorHandle(OciHandleType type, OciHandle parent, IntPtr newHandle)
     : base(type, parent, newHandle)
 {
 }
Ejemplo n.º 39
0
		public OciServiceHandle (OciHandle parent, IntPtr handle)
			: base (OciHandleType.Service, parent, handle)
		{
		}
Ejemplo n.º 40
0
 public OciServiceHandle(OciHandle parent, IntPtr handle)
     : base(OciHandleType.Service, parent, handle)
 {
 }