X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem.Data.OracleClient%2FSystem.Data.OracleClient.Oci%2FOciRowIdDescriptor.cs;h=040d61cadb84c8cd51ff6467409096f5e84d887f;hb=d531a7515eaad9fb1c2ca9fff160851fa70aa168;hp=fdf07acf03eda91149fbb5e0e4e842f34d8dd213;hpb=b6b13e72e91d5b529a6306ce53bda685932c77db;p=mono.git diff --git a/mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci/OciRowIdDescriptor.cs b/mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci/OciRowIdDescriptor.cs index fdf07acf03e..040d61cadb8 100644 --- a/mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci/OciRowIdDescriptor.cs +++ b/mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci/OciRowIdDescriptor.cs @@ -1,6 +1,6 @@ -// -// OciRowIdDescriptor.cs -// +// +// OciRowIdDescriptor.cs +// // Part of managed C#/.NET library System.Data.OracleClient.dll // // Part of the Mono class libraries at @@ -8,16 +8,19 @@ // // Assembly: System.Data.OracleClient.dll // Namespace: System.Data.OracleClient.Oci -// -// Author: +// +// Author: // Tim Coleman -// +// Daniel Morgan +// // Copyright (C) Tim Coleman, 2003 -// +// Copyright (C) Daniel Morgan, 2008 +// using System; using System.Data.OracleClient; using System.Runtime.InteropServices; +using System.Text; namespace System.Data.OracleClient.Oci { internal sealed class OciRowIdDescriptor : OciDescriptorHandle, IDisposable @@ -39,16 +42,6 @@ namespace System.Data.OracleClient.Oci { #region Methods - - //FIXME: This method only exists in Oracle 9i -/* - [DllImport ("oci")] - static extern int OCIRowidToChar (IntPtr rowidDesc, - IntPtr outbfp, - ref int outbflp, - IntPtr errhp); -*/ - protected override void Dispose (bool disposing) { if (!disposed) { @@ -57,19 +50,29 @@ namespace System.Data.OracleClient.Oci { } } - [MonoTODO ("Find a way to get this with 8 or 9.")] - public string GetRowId (OciErrorHandle errorHandle) + //FIXME: This method only exists in Oracle 9i client and above + [DllImport ("oci")] + static extern int OCIRowidToChar (IntPtr rowidDesc, + IntPtr outbfp, + ref ushort outbflp, + IntPtr errhp); + + [MonoTODO ("Only will work with 9i and above. Get it to work for 8i as well.")] + internal string GetRowIdToString (OciErrorHandle errorHandle) { string output = String.Empty; -/* - int len = 10; - IntPtr outputPtr = Marshal.AllocHGlobal (len); // FIXME: how big should this be? + + int len = 18; // Universal ROWID has a length of 18 + int maxByteCount = Encoding.UTF8.GetMaxByteCount (len); + IntPtr outputPtr = OciCalls.AllocateClear (maxByteCount); int status = 0; - status = OCIRowidToChar (this, + ushort u = (ushort) maxByteCount; + + status = OCIRowidToChar (Handle, outputPtr, - ref len, + ref u, errorHandle); if (status != 0) { @@ -77,17 +80,17 @@ namespace System.Data.OracleClient.Oci { throw new OracleException (info.ErrorCode, info.ErrorMessage); } - if (outputPtr != IntPtr.Zero && len > 0) { + if (outputPtr != IntPtr.Zero && maxByteCount > 0) { object str = Marshal.PtrToStringAnsi (outputPtr, len); if (str != null) output = String.Copy ((string) str); } -*/ - output = "NOT YET SUPPORTED."; return output; - } + } #endregion // Methods } } + +