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
, IDisposable
27 bool disposed
= false;
28 OciErrorHandle errorHandle
;
29 OciServiceHandle service
;
30 OciEnvironmentHandle environment
;
37 public OciLobLocator (OciHandle parent
, IntPtr handle
)
38 : base (OciHandleType
.LobLocator
, parent
, handle
)
42 #endregion // Constructors
46 public OciErrorHandle ErrorHandle
{
47 get { return errorHandle; }
48 set { errorHandle = value; }
51 public OciServiceHandle Service
{
52 get { return service; }
53 set { service = value; }
56 public OciDataType LobType
{
61 public OciEnvironmentHandle Environment
{
62 get { return environment; }
63 set { environment = value; }
66 #endregion // Properties
70 public void BeginBatch (OracleLobOpenMode mode
)
73 status
= OciCalls
.OCILobOpen (Service
,
79 OciErrorInfo info
= ErrorHandle
.HandleError ();
80 throw new OracleException (info
.ErrorCode
, info
.ErrorMessage
);
84 public uint Copy (OciLobLocator destination
, uint amount
, uint destinationOffset
, uint sourceOffset
)
86 OciCalls
.OCILobCopy (Service
,
96 protected override void Dispose (bool disposing
)
104 public void EndBatch ()
107 status
= OciCalls
.OCILobClose (Service
, ErrorHandle
, this);
110 OciErrorInfo info
= ErrorHandle
.HandleError ();
111 throw new OracleException (info
.ErrorCode
, info
.ErrorMessage
);
115 public uint Erase (uint offset
, uint amount
)
118 uint output
= amount
;
119 status
= OciCalls
.OCILobErase (Service
,
126 OciErrorInfo info
= ErrorHandle
.HandleError ();
127 throw new OracleException (info
.ErrorCode
, info
.ErrorMessage
);
133 public int GetChunkSize ()
137 status
= OciCalls
.OCILobGetChunkSize (Service
,
143 OciErrorInfo info
= ErrorHandle
.HandleError ();
144 throw new OracleException (info
.ErrorCode
, info
.ErrorMessage
);
150 public long GetLength (bool binary
)
154 status
= OciCalls
.OCILobGetLength (Service
,
159 OciErrorInfo info
= ErrorHandle
.HandleError ();
160 throw new OracleException (info
.ErrorCode
, info
.ErrorMessage
);
166 return (long) output
;
169 public int Read (byte[] buffer
, uint offset
, uint count
, bool binary
)
175 // Character types are UTF-16, so amount of characters is 1/2
176 // the amount of bytes
179 status
= OciCalls
.OCILobCharSetForm (environment
,
184 OciErrorInfo info
= ErrorHandle
.HandleError ();
185 throw new OracleException (info
.ErrorCode
, info
.ErrorMessage
);
189 status
= OciCalls
.OCILobRead (Service
,
202 OciErrorInfo info
= ErrorHandle
.HandleError ();
203 throw new OracleException (info
.ErrorCode
, info
.ErrorMessage
);
209 public void Trim (uint newlen
)
212 status
= OciCalls
.OCILobTrim (Service
,
218 OciErrorInfo info
= ErrorHandle
.HandleError ();
219 throw new OracleException (info
.ErrorCode
, info
.ErrorMessage
);
224 public int Write (byte[] buffer
, uint offset
, uint count
, OracleType type
)
229 if (type
== OracleType
.Clob
)
232 status
= OciCalls
.OCILobWrite (Service
,
246 OciErrorInfo info
= ErrorHandle
.HandleError ();
247 throw new OracleException (info
.ErrorCode
, info
.ErrorMessage
);
253 #endregion // Methods