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
;
36 public OciLobLocator (OciHandle parent
, IntPtr handle
)
37 : base (OciHandleType
.LobLocator
, parent
, handle
)
41 #endregion // Constructors
45 public OciErrorHandle ErrorHandle
{
46 get { return errorHandle; }
47 set { errorHandle = value; }
50 public OciServiceHandle Service
{
51 get { return service; }
52 set { service = value; }
55 public OciDataType LobType
{
60 #endregion // Properties
64 public void BeginBatch (OracleLobOpenMode mode
)
67 status
= OciCalls
.OCILobOpen (Service
,
73 OciErrorInfo info
= ErrorHandle
.HandleError ();
74 throw new OracleException (info
.ErrorCode
, info
.ErrorMessage
);
78 public uint Copy (OciLobLocator destination
, uint amount
, uint destinationOffset
, uint sourceOffset
)
80 OciCalls
.OCILobCopy (Service
,
90 protected override void Dispose (bool disposing
)
98 public void EndBatch ()
101 status
= OciCalls
.OCILobClose (Service
, ErrorHandle
, this);
104 OciErrorInfo info
= ErrorHandle
.HandleError ();
105 throw new OracleException (info
.ErrorCode
, info
.ErrorMessage
);
109 public uint Erase (uint offset
, uint amount
)
112 uint output
= amount
;
113 status
= OciCalls
.OCILobErase (Service
,
120 OciErrorInfo info
= ErrorHandle
.HandleError ();
121 throw new OracleException (info
.ErrorCode
, info
.ErrorMessage
);
127 public int GetChunkSize ()
131 status
= OciCalls
.OCILobGetChunkSize (Service
,
137 OciErrorInfo info
= ErrorHandle
.HandleError ();
138 throw new OracleException (info
.ErrorCode
, info
.ErrorMessage
);
144 public long GetLength (bool binary
)
148 status
= OciCalls
.OCILobGetLength (Service
,
153 OciErrorInfo info
= ErrorHandle
.HandleError ();
154 throw new OracleException (info
.ErrorCode
, info
.ErrorMessage
);
160 return (long) output
;
163 public int Read (byte[] buffer
, uint offset
, uint count
, bool binary
)
168 // Character types are UTF-16, so amount of characters is 1/2
169 // the amount of bytes
173 status
= OciCalls
.OCILobRead (Service
,
183 0); // Ignored if csid is specified as above
186 OciErrorInfo info
= ErrorHandle
.HandleError ();
187 throw new OracleException (info
.ErrorCode
, info
.ErrorMessage
);
193 public void Trim (uint newlen
)
196 status
= OciCalls
.OCILobTrim (Service
,
202 OciErrorInfo info
= ErrorHandle
.HandleError ();
203 throw new OracleException (info
.ErrorCode
, info
.ErrorMessage
);
208 public int Write (byte[] buffer
, uint offset
, uint count
, OracleType type
)
213 if (type
== OracleType
.Clob
)
216 status
= OciCalls
.OCILobWrite (Service
,
230 OciErrorInfo info
= ErrorHandle
.HandleError ();
231 throw new OracleException (info
.ErrorCode
, info
.ErrorMessage
);
237 #endregion // Methods