[Mono-bugs] [Bug 72677][Maj] Changed - Oracle : Invalid Argument in OCI call
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Sat, 19 Feb 2005 05:05:24 -0500 (EST)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by informatique.internet@fiducial.fr.
http://bugzilla.ximian.com/show_bug.cgi?id=72677
--- shadow/72677 2005-02-19 01:27:00.000000000 -0500
+++ shadow/72677.tmp.30799 2005-02-19 05:05:24.000000000 -0500
@@ -118,6 +118,83 @@
bindType = OciDataType.VarChar2; // FIXME
bindValue = Marshal.StringToHGlobalAnsi (value.ToString ());
bindSize = value.ToString ().Length;
}
+
+------- Additional Comments From informatique.internet@fiducial.fr 2005-02-19 05:05 -------
+I will test this next weeek...
+About DateTime I've posted something similar on the mailing list;
+I've got an answer today : I hope this could help you :
+
+>The default date format for Oracle is 'DD-MMM-YY'. Example: '13-FEB-
+02'
+
+>The fix needs to be able to handle situations where the date format
+could be changed via ALTER SESSION SET NLS_DATE_FORMAT, such as,
+
+>ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS';
+
+>I have some ideas on how to solve it:
+>1. OCINlsGetInfo can be used to get the date format. However, once I
+got this, I would need to reformat the date from OracleDateTime or
+DateTime to Oracle's date and vice-vesa.
+>2. (I haven't tried this yet - create DllImport's for OCI functions
+OCIDateTimeToText and OCIDateTimeFromText and calls these functions
+with
+an explicit
+ date format string. Oracle's OCIDate can stay as an IntPtr and use
+other OCI functions to deal with it.
+>3. There are even OCI functions to put the OCIDate into a byte array
+or
+get the OCIDate from a byte array. OCIDateTimeFromArray and
+OCIDateTimeToArray. DllImport's are needed for these functions too.
+
+>More info can be found in Oracle Call Interface Programmer's Guide.
+
+>http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96584/
+oci18m36.htm#512147
+**
+
+Here is working code so far...
+
+ private string GetSessionNlsDateFormat()
+ {
+ byte[] buffer = new Byte[64];
+ uint bufflen = (uint) buffer.Length;
+ ushort item = (ushort) OciNlsServiceType.DATEFORMAT;
+ IntPtr session = connection.Session;
+ int st = OciCalls.OCINlsGetInfo (session,
+connection.ErrorHandle,
+ ref buffer, bufflen, item);
+ // Get length of returned string
+ int rsize = 0;
+ IntPtr env = connection.Environment;
+ OciCalls.OCICharSetToUnicode (env, null, buffer, out rsize)
+;
+
+ // Get string
+ StringBuilder ret = new StringBuilder(rsize);
+ OciCalls.OCICharSetToUnicode (env, ret, buffer, out rsize);
+
+ string nlsDateFormat = ret.ToString ();
+ return nlsDateFormat;
+ }
+
+ internal static int OCINlsGetInfo (IntPtr hndl,
+ IntPtr errhp,
+ ref byte[] bufp,
+ uint buflen,
+ ushort item)
+ {
+ Trace.WriteLineIf(traceOci, "OCINlsGetInfo", "OCI");
+ return OciNativeCalls.OCINlsGetInfo (hndl, errhp, bufp,
+buflen, item);
+ }
+
+ [DllImport ("oci")]
+ internal static extern int OCINlsGetInfo (IntPtr hndl,
+ IntPtr errhp,
+ [In][Out] byte[] bufp,
+ uint buflen,
+ ushort item);