2 // OciRowIdDescriptor.cs
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>
14 // Daniel Morgan <monodanmorg@yahoo.com>
16 // Copyright (C) Tim Coleman, 2003
17 // Copyright (C) Daniel Morgan, 2008
21 using System.Data.OracleClient;
22 using System.Runtime.InteropServices;
25 namespace System.Data.OracleClient.Oci {
26 internal sealed class OciRowIdDescriptor : OciDescriptorHandle, IDisposable
30 bool disposed = false;
36 public OciRowIdDescriptor (OciHandle parent, IntPtr newHandle)
37 : base (OciHandleType.RowId, parent, newHandle)
41 #endregion // Constructors
45 protected override void Dispose (bool disposing)
49 base.Dispose (disposing);
53 //FIXME: This method only exists in Oracle 9i client and above
55 static extern int OCIRowidToChar (IntPtr rowidDesc,
60 [MonoTODO ("Only will work with 9i and above. Get it to work for 8i as well.")]
61 internal string GetRowIdToString (OciErrorHandle errorHandle)
63 string output = String.Empty;
65 int len = 18; // Universal ROWID has a length of 18
66 int maxByteCount = Encoding.UTF8.GetMaxByteCount (len);
67 IntPtr outputPtr = OciCalls.AllocateClear (maxByteCount);
71 ushort u = (ushort) maxByteCount;
73 status = OCIRowidToChar (Handle,
79 OciErrorInfo info = errorHandle.HandleError ();
80 throw new OracleException (info.ErrorCode, info.ErrorMessage);
83 if (outputPtr != IntPtr.Zero && maxByteCount > 0) {
84 object str = Marshal.PtrToStringAnsi (outputPtr, len);
86 output = String.Copy ((string) str);