Пример #1
0
        internal OciHandle Allocate(OciHandleType type)
        {
            int    status    = 0;
            IntPtr newHandle = IntPtr.Zero;

            if (type < OciHandleType.LobLocator)
            {
                status = OciCalls.OCIHandleAlloc(this,
                                                 out newHandle,
                                                 type,
                                                 0,
                                                 IntPtr.Zero);
            }
            else
            {
                status = OciCalls.OCIDescriptorAlloc(this,
                                                     out newHandle,
                                                     type,
                                                     0,
                                                     IntPtr.Zero);
            }

            if (status != 0 && status != 1)
            {
                throw new Exception(String.Format("Could not allocate new OCI Handle of type {0}", type));
            }

            switch (type)
            {
            case OciHandleType.Service:
                return(new OciServiceHandle(this, newHandle));

            case OciHandleType.Error:
                return(new OciErrorHandle(this, newHandle));

            case OciHandleType.Server:
                return(new OciServerHandle(this, newHandle));

            case OciHandleType.Session:
                return(new OciSessionHandle(this, newHandle));

            case OciHandleType.Statement:
                return(new OciStatementHandle(this, newHandle));

            case OciHandleType.Transaction:
                return(new OciTransactionHandle(this, newHandle));

            case OciHandleType.LobLocator:
                return(new OciLobLocator(this, newHandle));

            case OciHandleType.RowId:
                return(new OciRowIdDescriptor(this, newHandle));

            case OciHandleType.TimeStamp:
                return(new OciDateTimeDescriptor(this, newHandle));

            case OciHandleType.IntervalDayToSecond:
            case OciHandleType.IntervalYearToMonth:
                return(new OciIntervalDescriptor(this, type, newHandle));
            }
            return(null);
        }