4 // Part of managed C#/.NET library System.Data.OracleClient.dll
6 // Part of the Mono class libraries at
7 // mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
9 // Assembly: System.Data.OracleClient.dll
10 // Namespace: System.Data.OracleClient.Oci
13 // Tim Coleman <tim@timcoleman.com>
15 // Copyright (C) Tim Coleman, 2003
19 using System.Data.OracleClient;
20 using System.Runtime.InteropServices;
22 namespace System.Data.OracleClient.Oci {
23 internal sealed class OciLobLocator : OciDescriptorHandle, IOciDescriptorHandle, IDisposable
27 OciErrorHandle errorHandle;
28 OciServiceHandle service;
35 public OciLobLocator (OciEnvironmentHandle environment, IntPtr handle)
36 : base (OciDescriptorType.LobLocator, environment, handle)
40 #endregion // Constructors
44 public OciErrorHandle ErrorHandle {
45 get { return errorHandle; }
46 set { errorHandle = value; }
49 public OciServiceHandle Service {
50 get { return service; }
51 set { service = value; }
54 public OciDataType LobType {
59 #endregion // Properties
64 static extern int OCILobClose (IntPtr svchp,
69 static extern int OCILobErase (IntPtr svchp,
76 static extern int OCILobGetChunkSize (IntPtr svchp,
82 static extern int OCILobGetLength (IntPtr svchp,
88 static extern int OCILobOpen (IntPtr svchp,
94 static extern int OCILobRead (IntPtr svchp,
107 static extern int OCILobTrim (IntPtr svchp,
113 static extern int OCILobWrite (IntPtr svchp,
127 public void BeginBatch (OracleLobOpenMode mode)
130 status = OCILobOpen (service.Handle,
136 OciErrorInfo info = ErrorHandle.HandleError ();
137 throw new OracleException (info.ErrorCode, info.ErrorMessage);
141 public void EndBatch ()
144 status = OCILobClose (service.Handle,
149 OciErrorInfo info = ErrorHandle.HandleError ();
150 throw new OracleException (info.ErrorCode, info.ErrorMessage);
154 public uint Erase (uint offset, uint amount)
157 uint output = amount;
158 status = OCILobErase (service.Handle,
165 OciErrorInfo info = ErrorHandle.HandleError ();
166 throw new OracleException (info.ErrorCode, info.ErrorMessage);
172 public int GetChunkSize ()
176 status = OCILobGetChunkSize (service.Handle,
182 OciErrorInfo info = ErrorHandle.HandleError ();
183 throw new OracleException (info.ErrorCode, info.ErrorMessage);
189 public long GetLength (bool binary)
193 status = OCILobGetLength (service.Handle,
198 OciErrorInfo info = ErrorHandle.HandleError ();
199 throw new OracleException (info.ErrorCode, info.ErrorMessage);
205 return (long) output;
208 public int Read (byte[] buffer, uint offset, uint count, bool binary)
213 // Character types are UTF-16, so amount of characters is 1/2
214 // the amount of bytes
218 status = OCILobRead (service.Handle,
228 0); // Ignored if csid is specified as above
231 OciErrorInfo info = ErrorHandle.HandleError ();
232 throw new OracleException (info.ErrorCode, info.ErrorMessage);
238 public void Trim (uint newlen)
241 status = OCILobTrim (service.Handle,
247 OciErrorInfo info = ErrorHandle.HandleError ();
248 throw new OracleException (info.ErrorCode, info.ErrorMessage);
253 public int Write (byte[] buffer, uint offset, uint count, OracleType type)
258 if (type == OracleType.Clob)
261 status = OCILobWrite (service.Handle,
275 OciErrorInfo info = ErrorHandle.HandleError ();
276 throw new OracleException (info.ErrorCode, info.ErrorMessage);
282 public void Dispose ()
284 Environment.FreeDescriptor (this);
287 #endregion // Methods