**** Merged from MCS ****
[mono-project.git] / mcs / class / System.Data.OracleClient / System.Data.OracleClient.Oci / OciRowIdDescriptor.cs
blobe657e56566c32fdff4a84fb5b7714d7aa611ed7b
1 //
2 // OciRowIdDescriptor.cs
3 //
4 // Part of managed C#/.NET library System.Data.OracleClient.dll
5 //
6 // Part of the Mono class libraries at
7 // mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
8 //
9 // Assembly: System.Data.OracleClient.dll
10 // Namespace: System.Data.OracleClient.Oci
11 //
12 // Author:
13 // Tim Coleman <tim@timcoleman.com>
14 //
15 // Copyright (C) Tim Coleman, 2003
16 //
18 using System;
19 using System.Data.OracleClient;
20 using System.Runtime.InteropServices;
22 namespace System.Data.OracleClient.Oci {
23 internal sealed class OciRowIdDescriptor : OciDescriptorHandle, IDisposable
25 #region Fields
27 bool disposed = false;
29 #endregion // Fields
31 #region Constructors
33 public OciRowIdDescriptor (OciHandle parent, IntPtr newHandle)
34 : base (OciHandleType.RowId, parent, newHandle)
38 #endregion // Constructors
40 #region Methods
43 FIXME: This method only exists in Oracle 9i
45 [DllImport ("oci")]
46 static extern int OCIRowidToChar (IntPtr rowidDesc,
47 IntPtr outbfp,
48 ref int outbflp,
49 IntPtr errhp);
52 protected override void Dispose (bool disposing)
54 if (!disposed) {
55 disposed = true;
56 base.Dispose (disposing);
60 [MonoTODO ("Find a way to get this with 8 or 9.")]
61 public string GetRowId (OciErrorHandle errorHandle)
63 string output = String.Empty;
65 int len = 64;
66 IntPtr outputPtr = Marshal.AllocHGlobal (len); // FIXME: how big should this be?
68 int status = 0;
70 status = OCIRowidToChar (this,
71 outputPtr,
72 ref len,
73 errorHandle);
75 if (status != 0) {
76 OciErrorInfo info = errorHandle.HandleError ();
77 throw new OracleException (info.ErrorCode, info.ErrorMessage);
80 if (outputPtr != IntPtr.Zero && len > 0) {
81 object str = Marshal.PtrToStringAnsi (outputPtr, len);
82 if (str != null)
83 output = String.Copy ((string) str);
87 output = "NOT YET SUPPORTED.";
89 return output;
92 #endregion // Methods