Inheritance: System.SystemException
        internal void CheckError(OciHandle errorHandle, int rc)
        {
            // Check the return code and perform the appropriate handling; either
            // throwing the exception or posting a warning message.
            switch ((OCI.RETURNCODE)rc)
            {
            case OCI.RETURNCODE.OCI_ERROR:                              // -1: Bad programming by the customer.
                throw ADP.OracleError(errorHandle, rc, ScratchBuffer);

            case OCI.RETURNCODE.OCI_INVALID_HANDLE:                     // -2: Bad programming on my part.
                throw ADP.InvalidOperation(Res.GetString(Res.ADP_InternalError, rc));

            case OCI.RETURNCODE.OCI_SUCCESS_WITH_INFO:                  // 1: Information Message
                OracleException            infoMessage      = new OracleException(errorHandle, rc, ScratchBuffer);
                OracleInfoMessageEventArgs infoMessageEvent = new OracleInfoMessageEventArgs(infoMessage);
                OnInfoMessage(infoMessageEvent);
                break;

            default:
                if (rc < 0 || rc == (int)OCI.RETURNCODE.OCI_NEED_DATA)
                {
                    throw ADP.Simple(Res.GetString(Res.ADP_UnexpectedReturnCode, rc.ToString(CultureInfo.CurrentCulture)));
                }

                Debug.Assert(false, "Unexpected return code: " + rc);                    // shouldn't be here for any reason.
                break;
            }
        }
Esempio n. 2
0
        internal void SetAttribute(
            OCI.ATTR attribute,
            string value,
            OciHandle errorHandle
            )
        {
            int valueLengthAsChars = value.Length;

            byte[] valueAsBytes       = new byte[valueLengthAsChars * 4];
            int    valueLengthAsBytes = GetBytes(value.ToCharArray(), 0, valueLengthAsChars, valueAsBytes, 0);

            int rc = TracedNativeMethods.OCIAttrSet(
                this,                       // trgthndlp/trghndltyp
                valueAsBytes,               // attributep
                valueLengthAsBytes,         // size
                attribute,                  // attrtype
                errorHandle                 // errhp
                );

            if (0 != rc)
            {
                OracleException.Check(errorHandle, rc);
            }

            GC.KeepAlive(this);
        }
        /// <summary>
        /// Oracle錯誤訊息判別
        /// </summary>
        /// <param name="oex">傳入Oracle的錯誤物件</param>
        /// <param name="USEDB">傳入參考的DB</param>
        public Exception OracleExceptionProxy(OracleException oex,
                                              Database USEDB
                                              )
        {
            ArrayList ParameterList = new ArrayList();

            #region 輸入變數

            ParameterList.Clear();
            //Oracle 錯誤代碼
            ParameterList.Add(oex.Code);

            #endregion

            string pmSqlExceptionMessage = ExceptionMessage(ParameterList,
                                                            USEDB
                                                            );

            if (pmSqlExceptionMessage.Length != 0)//有自定義的錯誤訊息
            {
                //this.SaveSqlErrorLog(oex, "AP SERVER 已處理");
                return new Exception(pmSqlExceptionMessage);
            }
            else
            {
                return oex;
            }            
        }
Esempio n. 4
0
        internal OciHandle GetDescriptor(
            int i,
            OciHandle errorHandle
            )
        {
            //  Wraps the OCIParamGet call. We do not expect it to fail, so we
            //  will throw if it does.

            IntPtr paramdesc;
            int    rc = TracedNativeMethods.OCIParamGet(
                this,
                errorHandle,
                out paramdesc,
                i + 1
                );

            if (0 != rc)
            {
                OracleException.Check(errorHandle, rc);
            }

            OciHandle result = new OciParameterDescriptor(this, paramdesc);

            GC.KeepAlive(this);
            return(result);
        }
Esempio n. 5
0
        ////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////
        //
        // Constructors
        //
        ////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////

        internal OciEnlistContext(
            string userName,
            string password,
            string serverName,
            OciHandle serviceContextHandle,
            OciHandle errorHandle)
        {
            _enlistContext        = IntPtr.Zero;
            _serviceContextHandle = serviceContextHandle;

            int rc = 0;

            try {
                rc = TracedNativeMethods.OraMTSEnlCtxGet(userName, password, serverName, _serviceContextHandle, errorHandle, 0, out _enlistContext);
            }
            catch (DllNotFoundException e)
            {
                ADP.DistribTxRequiresOracleServicesForMTS(e);
            }

            if (0 != rc)
            {
                OracleException.Check(errorHandle, rc);
            }
        }
Esempio n. 6
0
        private static void InternalTrunc(OciErrorHandle errorHandle, byte[] n, int position, byte[] result)
        {
            int rc = System.Data.Common.UnsafeNativeMethods.OCINumberTrunc(errorHandle, n, position, result);

            if (rc != 0)
            {
                OracleException.Check(errorHandle, rc);
            }
        }
Esempio n. 7
0
        private static void InternalSub(OciErrorHandle errorHandle, byte[] x, byte[] y, byte[] result)
        {
            int rc = System.Data.Common.UnsafeNativeMethods.OCINumberSub(errorHandle, x, y, result);

            if (rc != 0)
            {
                OracleException.Check(errorHandle, rc);
            }
        }
Esempio n. 8
0
        private static void InternalShift(OciErrorHandle errorHandle, byte[] n, int digits, byte[] result)
        {
            int rc = System.Data.Common.UnsafeNativeMethods.OCINumberShift(errorHandle, n, digits, result);

            if (rc != 0)
            {
                OracleException.Check(errorHandle, rc);
            }
        }
        internal void SetAttribute(OCI.ATTR attribute, int value, OciErrorHandle errorHandle)
        {
            int rc = TracedNativeMethods.OCIAttrSet(this, ref value, 0, attribute, errorHandle);

            if (rc != 0)
            {
                OracleException.Check(errorHandle, rc);
            }
        }
Esempio n. 10
0
        private static void FromUInt64(OciErrorHandle errorHandle, ulong ulongValue, byte[] result)
        {
            int rc = System.Data.Common.UnsafeNativeMethods.OCINumberFromInt(errorHandle, ref ulongValue, 8, OCI.SIGN.OCI_NUMBER_UNSIGNED, result);

            if (rc != 0)
            {
                OracleException.Check(errorHandle, rc);
            }
        }
Esempio n. 11
0
        internal void Join(OracleInternalConnection internalConnection, Transaction indigoTransaction)
        {
            IDtcTransaction oletxTransaction = System.Data.Common.ADP.GetOletxTransaction(indigoTransaction);
            int             rc = TracedNativeMethods.OraMTSJoinTxn(this, oletxTransaction);

            if (rc != 0)
            {
                OracleException.Check(rc, internalConnection);
            }
        }
        internal void GetAttribute(OCI.ATTR attribute, out int value, OciErrorHandle errorHandle)
        {
            uint sizep = 0;
            int  rc    = TracedNativeMethods.OCIAttrGet(this, out value, out sizep, attribute, errorHandle);

            if (rc != 0)
            {
                OracleException.Check(errorHandle, rc);
            }
        }
Esempio n. 13
0
        private static int InternalSign(OciErrorHandle errorHandle, byte[] n)
        {
            int num2;
            int rc = System.Data.Common.UnsafeNativeMethods.OCINumberSign(errorHandle, n, out num2);

            if (rc != 0)
            {
                OracleException.Check(errorHandle, rc);
            }
            return(num2);
        }
Esempio n. 14
0
        internal void Join(ITransaction transaction)
        {
            int rc = TracedNativeMethods.OraMTSJoinTxn(Handle, transaction);

            if (0 != rc)
            {
                OracleException.Check(rc);
            }

            _transaction = transaction;
        }
        internal void Commit()
        {
            int rc = TracedNativeMethods.OCITransCommit(this.ServiceContextHandle, this.ErrorHandle, OCI.MODE.OCI_DEFAULT);

            if (rc != 0)
            {
                OracleException.Check(this.ErrorHandle, rc);
            }
            this.TransactionState = System.Data.OracleClient.TransactionState.AutoCommit;
            this.Transaction      = null;
        }
Esempio n. 16
0
        internal OciParameterDescriptor GetDescriptor(int i, OciErrorHandle errorHandle)
        {
            IntPtr ptr;
            int    rc = TracedNativeMethods.OCIParamGet(this, base.HandleType, errorHandle, out ptr, i + 1);

            if (rc != 0)
            {
                OracleException.Check(errorHandle, rc);
            }
            return(new OciParameterDescriptor(this, ptr));
        }
        private void CreateDeferredInfoMessage(OciErrorHandle errorHandle, int rc)
        {
            OracleInfoMessageEventArgs        item = new OracleInfoMessageEventArgs(OracleException.CreateException(errorHandle, rc));
            List <OracleInfoMessageEventArgs> list = this._deferredInfoMessageCollection;

            if (list == null)
            {
                list = this._deferredInfoMessageCollection = new List <OracleInfoMessageEventArgs>();
            }
            list.Add(item);
        }
Esempio n. 18
0
        private static ulong ToUInt64(OciErrorHandle errorHandle, byte[] value)
        {
            ulong num2;
            int   rc = System.Data.Common.UnsafeNativeMethods.OCINumberToInt(errorHandle, value, 8, OCI.SIGN.OCI_NUMBER_UNSIGNED, out num2);

            if (rc != 0)
            {
                OracleException.Check(errorHandle, rc);
            }
            return(num2);
        }
Esempio n. 19
0
        private static void FromDouble(OciErrorHandle errorHandle, double dblValue, byte[] result)
        {
            if ((dblValue < doubleMinValue) || (dblValue > doubleMaxValue))
            {
                throw System.Data.Common.ADP.OperationResultedInOverflow();
            }
            int rc = System.Data.Common.UnsafeNativeMethods.OCINumberFromReal(errorHandle, ref dblValue, 8, result);

            if (rc != 0)
            {
                OracleException.Check(errorHandle, rc);
            }
        }
        internal void SetAttribute(OCI.ATTR attribute, string value, OciErrorHandle errorHandle)
        {
            uint length = (uint)value.Length;

            byte[] bytes = new byte[length * 4];
            uint   size  = this.GetBytes(value.ToCharArray(), 0, length, bytes, 0);
            int    rc    = TracedNativeMethods.OCIAttrSet(this, bytes, size, attribute, errorHandle);

            if (rc != 0)
            {
                OracleException.Check(errorHandle, rc);
            }
        }
        internal void GetAttribute(OCI.ATTR attribute, out string value, OciErrorHandle errorHandle, OracleConnection connection)
        {
            IntPtr zero  = IntPtr.Zero;
            uint   sizep = 0;
            int    rc    = TracedNativeMethods.OCIAttrGet(this, ref zero, ref sizep, attribute, errorHandle);

            if (rc != 0)
            {
                OracleException.Check(errorHandle, rc);
            }
            byte[] destination = new byte[sizep];
            Marshal.Copy(zero, destination, 0, (int)sizep);
            value = connection.GetString(destination);
        }
Esempio n. 22
0
        internal void GetRowid(OciStatementHandle statementHandle, OciErrorHandle errorHandle)
        {
            uint sizep = 0;
            int  rc    = TracedNativeMethods.OCIAttrGet(statementHandle, this, out sizep, OCI.ATTR.OCI_ATTR_ROWID, errorHandle);

            if (100 == rc)
            {
                base.Dispose();
            }
            else if (rc != 0)
            {
                OracleException.Check(errorHandle, rc);
            }
        }
Esempio n. 23
0
        protected override Exception InternalWrapException(Exception exception, string statement)
        {
            Oracle.OracleException oracleException = exception as Oracle.OracleException;
            if (oracleException != null)
            {
                if (oracleException.Code == 1422)
                {
                    return(new Runtime.RuntimeException(Runtime.RuntimeException.Codes.InvalidRowExtractorExpression));
                }
            }

            // Wrap all exceptions coming back with a simple Exception so that it crosses the boundary.
            return(new ConnectionException(ConnectionException.Codes.SQLException, ErrorSeverity.Application, new Exception(exception.Message), statement));
        }
Esempio n. 24
0
        public static string GetOracleExceptionText(OracleException ex)
        {
            string text = "äÁèÊÒÁÒö·ÓÃÒ¡ÒÃä´é ";
            switch (ex.Code.ToString())
            {
                case "2292" :
                    text = text + " à¹×èͧ¨Ò¡ÃÒ¡Ò÷Õèá¡éä¢ ÁռšѺÃÒ¡ÒÃÍ×è¹";
                    break;

                default :
                    text = ex.Message;
                    break;
            }
            return text;
        }
Esempio n. 25
0
        private static string ToString(OciErrorHandle errorHandle, byte[] value)
        {
            byte[] buffer = new byte[0x40];
            uint   length = (uint)buffer.Length;
            int    rc     = System.Data.Common.UnsafeNativeMethods.OCINumberToText(errorHandle, value, "TM9", 3, IntPtr.Zero, 0, ref length, buffer);

            if (rc != 0)
            {
                OracleException.Check(errorHandle, rc);
            }
            int index = Array.IndexOf <byte>(buffer, 0x3a);

            index = (index > 0) ? index : Array.LastIndexOf(buffer, 0);
            return(Encoding.Default.GetString(buffer, 0, (index > 0) ? index : ((int)length)));
        }
Esempio n. 26
0
        internal void GetAttribute(
            OCI.ATTR attribute,
            out int value,
            OciHandle errorHandle
            )
        {
            int zero = 0;
            int rc   = TracedNativeMethods.OCIAttrGet(this, out value, out zero, attribute, errorHandle);

            if (0 != rc)
            {
                OracleException.Check(errorHandle, rc);
            }

            GC.KeepAlive(this);
        }
Esempio n. 27
0
        public static OracleNumber Floor(OracleNumber n)
        {
            if (n.IsNull)
            {
                return(Null);
            }
            OracleConnection.ExecutePermission.Demand();
            OciErrorHandle errorHandle = TempEnvironment.GetErrorHandle();
            OracleNumber   number      = new OracleNumber(false);
            int            rc          = System.Data.Common.UnsafeNativeMethods.OCINumberFloor(errorHandle, n._value, number._value);

            if (rc != 0)
            {
                OracleException.Check(errorHandle, rc);
            }
            return(number);
        }
Esempio n. 28
0
        internal void GetAttribute(
            OCI.ATTR attribute,
            out string value,
            OciHandle errorHandle,
            OracleConnection connection
            )
        {
            IntPtr tempptr;
            int    tempub4;
            int    rc = TracedNativeMethods.OCIAttrGet(this, out tempptr, out tempub4, attribute, errorHandle);

            if (0 != rc)
            {
                OracleException.Check(errorHandle, rc);
            }

            value = connection.GetString(tempptr, tempub4, false);

            GC.KeepAlive(this);
        }
Esempio n. 29
0
        internal void SetAttribute(
            OCI.ATTR attribute,
            OciHandle value,
            OciHandle errorHandle
            )
        {
            int rc = TracedNativeMethods.OCIAttrSet(
                this,                   // trgthndlp/trghndltyp
                value,                  // attributep
                0,                      // size
                attribute,              // attrtype
                errorHandle             // errhp
                );

            if (0 != rc)
            {
                OracleException.Check(errorHandle, rc);
            }

            GC.KeepAlive(this);
        }
Esempio n. 30
0
 private void FromStringOfDigits(OciErrorHandle errorHandle, string s, byte[] result)
 {
     if (s.Length <= 0x3f)
     {
         int rc = System.Data.Common.UnsafeNativeMethods.OCINumberFromText(errorHandle, s, (uint)s.Length, "999999999999999999999999999999999999999999999999999999999999999", 0x3f, IntPtr.Zero, 0, result);
         if (rc != 0)
         {
             OracleException.Check(errorHandle, rc);
         }
     }
     else
     {
         byte[] buffer = new byte[0x16];
         string str2   = s.Substring(0, 0x3f);
         string str    = s.Substring(0x3f);
         this.FromStringOfDigits(errorHandle, str2, buffer);
         this.FromStringOfDigits(errorHandle, str, result);
         InternalShift(errorHandle, buffer, str.Length, buffer);
         InternalAdd(errorHandle, result, buffer, result);
     }
 }
Esempio n. 31
0
        internal OciHandle GetRowid(
            OciHandle environmentHandle,
            OciHandle errorHandle
            )
        {
            OciHandle rowidHandle = new OciRowidDescriptor(environmentHandle);

            int zero = 0;
            int rc   = TracedNativeMethods.OCIAttrGet(this, rowidHandle, out zero, OCI.ATTR.OCI_ATTR_ROWID, errorHandle);

            if ((int)OCI.RETURNCODE.OCI_NO_DATA == rc)
            {
                SafeDispose(ref rowidHandle);
            }
            else if (0 != rc)
            {
                OracleException.Check(errorHandle, rc);
            }

            GC.KeepAlive(this);
            return(rowidHandle);
        }
Esempio n. 32
0
        public static tgConcurrencyException CheckForConcurrencyException(OracleException ex)
        {
            tgConcurrencyException ce = null;

            if (ex.Code == 20101)
            {
                ce = new tgConcurrencyException(ex.Message, ex);
                ce.Source = ex.Source;
            }

            return ce;
        }
Esempio n. 33
0
 private void ProcesarExcepcion(OracleException pExcepcion)
 {
     IsError = true;
     ErrorDescripcion += " \n" + pExcepcion.Message + " \n";
     ErrorDescripcion += pExcepcion.ErrorCode + " \n";
     ErrorDescripcion += pExcepcion.StackTrace;
 }
Esempio n. 34
0
 public static void ExceptionLog(OracleException oracleEx)
 {
     logger.Fatal("An Oracle Exception occured at Method Name  : {0}" + oracleEx.TargetSite.ToString());
     logger.Debug("Exception Description  : {0}" + oracleEx.Message.ToString());
 }
 internal OracleInfoMessageEventArgs(OracleException exception)
 {
     this.exception = exception;
 }
Esempio n. 36
0
 internal OracleInfoMessageEventArgs(OracleException exception)
 {
     this.exception = exception;
 }