public void EndBatch() { int status = 0; status = OciCalls.OCILobClose(Service, ErrorHandle, this); if (status != 0) { OciErrorInfo info = ErrorHandle.HandleError(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } }
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 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 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); } }
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 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 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); }
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 bool Fetch() { int status = 0; if (this.disposed) { throw new InvalidOperationException("StatementHandle is already disposed."); } status = OciCalls.OCIStmtFetch(Handle, ErrorHandle.Handle, 1, 2, 0); switch (status) { case OciGlue.OCI_NO_DATA: moreResults = false; foreach (IntPtr h in parm) { OciCalls.OCIDescriptorFree(h, OciHandleType.Parameter); } break; case OciGlue.OCI_DEFAULT: moreResults = true; break; case OciGlue.OCI_SUCCESS_WITH_INFO: //OciErrorInfo ei = ErrorHandle.HandleError (); //command.Connection.CreateInfoMessage (ei); moreResults = true; break; default: OciErrorInfo info = ErrorHandle.HandleError(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } return(moreResults); }
void DefineLongVarChar(int position, OracleConnection connection) { fieldType = typeof(System.String); // LONG VARCHAR max length is 2 to the 31 power - 5 // the first 4 bytes of a LONG VARCHAR value contains the length // Int32.MaxValue - 5 causes out of memory in mono on win32 // because I do not have 2GB of memory available // so Int16.MaxValue - 5 is used instead. // LAMESPEC for Oracle OCI - you can not get the length of the LONG VARCHAR value // until after you get the value. This could be why Oracle deprecated LONG VARCHAR. // If you specify a definedSize less then the length of the column value, // then you will get an OCI_ERROR ORA-01406: fetched column value was truncated // TODO: get via piece-wise - a chunk at a time definedSize = LongVarCharMaxValue; value = OciCalls.AllocateClear(definedSize); ociType = OciDataType.LongVarChar; int status = 0; status = OciCalls.OCIDefineByPos(Parent, out handle, ErrorHandle, position + 1, value, definedSize, ociType, indicator, rlenp, IntPtr.Zero, 0); Size = (short)definedSize; if (status != 0) { OciErrorInfo info = ErrorHandle.HandleError(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } }
public void Prepare(string commandText) { int status = 0; if (this.disposed) { throw new InvalidOperationException("StatementHandle is already disposed."); } ulong rsize = 0; byte [] buffer; UIntPtr rsizep = new UIntPtr(rsize); // Get size of buffer OciCalls.OCIUnicodeToCharSet(Parent, null, commandText, ref rsizep); rsize = rsizep.ToUInt64(); //rsize = Encoding.UTF8.GetMaxByteCount (commandText.Length+1); // Fill buffer buffer = new byte[rsize]; OciCalls.OCIUnicodeToCharSet(Parent, buffer, commandText, ref rsizep); // Execute statement status = OciCalls.OCIStmtPrepare(this, ErrorHandle, buffer, buffer.Length, OciStatementLanguage.NTV, OciStatementMode.Default); if (status != 0) { OciErrorInfo info = ErrorHandle.HandleError(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } }
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); }
public OciParameterDescriptor GetParameter(int position) { IntPtr handle = IntPtr.Zero; int status = 0; status = OciCalls.OCIParamGet(this, OciHandleType.Statement, ErrorHandle, out handle, position + 1); if (status != 0) { OciErrorInfo info = ErrorHandle.HandleError(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } OciParameterDescriptor output = new OciParameterDescriptor(this, handle); output.ErrorHandle = ErrorHandle; return(output); }
public bool Execute(bool nonQuery, bool useAutoCommit, bool schemaOnly) { int status = 0; columnCount = 0; moreResults = false; int executeMode; if (useAutoCommit) { executeMode = (int)OciExecuteMode.CommitOnSuccess; } else { if (schemaOnly) { executeMode = (int)OciExecuteMode.DescribeOnly; } else { executeMode = (int)OciExecuteMode.Default; } } if (this.disposed) { throw new InvalidOperationException("StatementHandle is already disposed."); } status = OciCalls.OCIStmtExecute(Service, Handle, ErrorHandle, nonQuery, 0, IntPtr.Zero, IntPtr.Zero, (OciExecuteMode)executeMode); switch (status) { case OciGlue.OCI_DEFAULT: if (!nonQuery) { GetColumnCount(); Define(); moreResults = true; } break; case OciGlue.OCI_NO_DATA: break; case OciGlue.OCI_INVALID_HANDLE: throw new OracleException(0, "Invalid handle."); default: OciErrorInfo info = ErrorHandle.HandleError(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } return(true); }