public void BeginBatch(OracleLobOpenMode mode)
        {
            int status = 0;

            status = OciCalls.OCILobOpen(Service,
                                         ErrorHandle,
                                         Handle,
                                         (byte)mode);

            if (status != 0)
            {
                OciErrorInfo info = ErrorHandle.HandleError();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }
        }
        public void Detach(OciErrorHandle error)
        {
            if (!attached)
                return;

            int status = OciCalls.OCIServerDetach(this, error, 0);

            if (status != 0)
            {
                OciErrorInfo info = errorHandle.HandleError();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }

            attached = false;
        }
        public void Trim(uint newlen)
        {
            int status = 0;

            status = OciCalls.OCILobTrim(Service,
                                         ErrorHandle,
                                         this,
                                         newlen);

            if (status != 0)
            {
                OciErrorInfo info = ErrorHandle.HandleError();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }
        }
        public bool Attach(string tnsname, OciErrorHandle error)
        {
            errorHandle = error;

            int status = OciCalls.OCIServerAttach(this, error, tnsname, tnsname.Length, 0);

            if (status != 0)
            {
                OciErrorInfo info = errorHandle.HandleError();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }

            attached = true;
            return attached;
        }
Ejemplo n.º 5
0
        public void DetachFromServiceContext()
        {
            int status = 0;

            status = OciCalls.OCIAttrSet(Service,
                                         OciHandleType.Service,
                                         IntPtr.Zero,
                                         0,
                                         OciAttributeType.Transaction,
                                         ErrorHandle);
            if (status != 0)
            {
                OciErrorInfo info = ErrorHandle.HandleError();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }
        }
Ejemplo n.º 6
0
        public void Begin()
        {
            int status = 0;

            AttachToServiceContext();

            status = OciCalls.OCITransStart(Service,
                                            ErrorHandle,
                                            60,
                                            OciTransactionFlags.New);

            if (status != 0)
            {
                OciErrorInfo info = ErrorHandle.HandleError();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }
        }
        public int GetChunkSize()
        {
            int  status = 0;
            uint output;

            status = OciCalls.OCILobGetChunkSize(Service,
                                                 ErrorHandle,
                                                 this,
                                                 out output);

            if (status != 0)
            {
                OciErrorInfo info = ErrorHandle.HandleError();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }

            return((int)output);
        }
        public uint Erase(uint offset, uint amount)
        {
            int  status = 0;
            uint output = amount;

            status = OciCalls.OCILobErase(Service,
                                          ErrorHandle,
                                          this,
                                          ref output,
                                          (uint)offset);

            if (status != 0)
            {
                OciErrorInfo info = ErrorHandle.HandleError();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }

            return(output);
        }
Ejemplo n.º 9
0
        public void Rollback()
        {
            try
            {
                int status = 0;
                AttachToServiceContext();
                status = OciCalls.OCITransRollback(Service, ErrorHandle, 0);

                if (status != 0)
                {
                    OciErrorInfo info = ErrorHandle.HandleError();
                    throw new OracleException(info.ErrorCode, info.ErrorMessage);
                }
            }
            finally
            {
                DetachFromServiceContext();
            }
        }
        public int Read(byte[] buffer, uint offset, uint count, bool binary)
        {
            int  status = 0;
            uint amount = count;
            byte csfrm  = 0;

            // Character types are UTF-16, so amount of characters is 1/2
            // the amount of bytes
            if (!binary)
            {
                amount /= 2;
                status  = OciCalls.OCILobCharSetForm(environment,
                                                     ErrorHandle,
                                                     this,
                                                     out csfrm);
                if (status != 0)
                {
                    OciErrorInfo info = ErrorHandle.HandleError();
                    throw new OracleException(info.ErrorCode, info.ErrorMessage);
                }
            }

            status = OciCalls.OCILobRead(Service,
                                         ErrorHandle,
                                         this,
                                         ref amount,
                                         offset,
                                         buffer,
                                         count,
                                         IntPtr.Zero,
                                         IntPtr.Zero,
                                         1000, // OCI_UCS2ID
                                         csfrm);

            if (status != 0)
            {
                OciErrorInfo info = ErrorHandle.HandleError();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }

            return((int)amount);
        }
        public long GetLength(bool binary)
        {
            int  status = 0;
            uint output;

            status = OciCalls.OCILobGetLength(Service,
                                              ErrorHandle,
                                              this,
                                              out output);
            if (status != 0)
            {
                OciErrorInfo info = ErrorHandle.HandleError();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }

            if (!binary)
            {
                output *= 2;
            }

            return((long)output);
        }
Ejemplo n.º 12
0
 internal OracleInfoMessageEventArgs(OciErrorInfo info)
 {
     code    = info.ErrorCode;
     message = info.ErrorMessage;
 }
Ejemplo n.º 13
0
        public void CreateConnection(OracleConnectionInfo conInfo)
        {
            environment = new OciEnvironmentHandle(OciEnvironmentMode.Threaded | OciEnvironmentMode.NoUserCallback);

            if (environment.Handle == IntPtr.Zero)
            {
                throw new OracleException(0, "Could not allocate the Oracle environment.");
            }

            service = (OciServiceHandle)environment.Allocate(OciHandleType.Service);
            if (service == null)
            {
                OciErrorInfo info = environment.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }

            error = (OciErrorHandle)environment.Allocate(OciHandleType.Error);
            if (error == null)
            {
                OciErrorInfo info = environment.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }
            service.ErrorHandle = error;

            server = (OciServerHandle)environment.Allocate(OciHandleType.Server);
            if (server == null)
            {
                OciErrorInfo info = environment.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }

            session = (OciSessionHandle)environment.Allocate(OciHandleType.Session);
            if (session == null)
            {
                OciErrorInfo info = environment.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }
            session.Username = conInfo.Username;
            session.Password = conInfo.Password;
            session.Service  = service;

            if (!server.Attach(conInfo.Database, ErrorHandle))
            {
                OciErrorInfo info = error.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }

            if (!service.SetServer(server))
            {
                OciErrorInfo info = error.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }

#if ORACLE_DATA_ACCESS
            if (conInfo.SetNewPassword == true)
            {
                // open with new password
                if (!service.SetSession(session))
                {
                    OciErrorInfo info = error.HandleError();
                    Disconnect();
                    throw new OracleException(info.ErrorCode, info.ErrorMessage);
                }
                if (!service.ChangePassword(conInfo.NewPassword, error))
                {
                    OciErrorInfo info = error.HandleError();
                    Disconnect();
                    throw new OracleException(info.ErrorCode, info.ErrorMessage);
                }
                conInfo.Password       = conInfo.NewPassword;
                conInfo.SetNewPassword = false;
                conInfo.NewPassword    = string.Empty;
            }
            else
            {
#endif
            // open normally
            if (!session.BeginSession(conInfo.CredentialType, OciSessionMode.Default, ErrorHandle))
            {
                OciErrorInfo info = error.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }

            if (!service.SetSession(session))
            {
                OciErrorInfo info = error.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }
#if ORACLE_DATA_ACCESS
        }
#endif
            connected = true;
        }
Ejemplo n.º 14
0
        public OciErrorInfo HandleError()
        {
            OciErrorInfo info = OciErrorHandle.HandleError(this);

            return(info);
        }