[Mono-devel-list] TimeStamp support on oracle...

Daniel Morgan danielmorgan at verizon.net
Thu Jul 28 20:48:02 EDT 2005


You need to modify OciDefineHandle to deal with the TIMESTAMP.

See Define(), DefineDate(), and GetValue().

You can create a new function called DefineTimestamp() based on 
DefineDate() and allocate space for it based OciDataType.TimeStamp.

What about TIMESTAMP WITH TIMEZONE and TIMESTAMP WITH LOCAL TIMEZONE?

There is also INTERVAL YEAR TO MONTH and INTERVAL DAY TO SECOND data 
types. This is equivalent to System.TimeSpan and 
System.Data.OracleClient types OracleMonthSpan and OracleTimeSpan.   
These have not been implemented either.

Also, in OracleParameter, you need to allocate space for the Timestamp 
for the output parameter, and you need to convert a .NET DateTime to an 
Oracle TIMESTAMP by using OCIDateTime functions for the input parameter.

An Oracle Date uses OCIDate while TIMESTAMP uses an OCIDateTime.

You will need to DllImport into function OCIDateTimeConstruct() to 
create and set the date and time in a OCIDateTime.  You will also need 
to DllImport into function OCIDateTimeGetTime() to get the time from the 
OCIDateTime and OCIDateTimeGetDate() to get the date from the 
OCIDateTime.  There are other functions for the time zone, etc...

http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14250/oci18map002.htm#i512069

Hubert FONGARNAND wrote:

>I really need the new TimeStamp type (supported starting from oracle 9). It's 
>a MS.NET supported type (i've made tests)...
>I've begin to do a little patch (attached) to add the timestamp type to 
>oracle.client...
>but... I've a strange error when i try to do a Fill, it failed with:
>
>Unhandled Exception: System.Data.OracleClient.OracleException:
>in <0x0013d> System.Data.OracleClient.Oci.OciStatementHandle:Fetch ()
>in <0x0002c> System.Data.OracleClient.OracleDataReader:Read ()
>in <0x002f4> System.Data.Common.DbDataAdapter:FillTable (System.Data.DataTable 
>dataTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords, 
>System.Int32 counter)
>in <0x0011f> System.Data.Common.DbDataAdapter:Fill (System.Data.DataSet 
>dataSet, System.String srcTable, IDataReader dataReader, Int32 startRecord, 
>Int32 maxRecords)
>in <0x000d5> System.Data.Common.DbDataAdapter:Fill (System.Data.DataSet 
>dataSet, Int32 startRecord, Int32 maxRecords, System.String srcTable, 
>IDbCommand command, CommandBehavior behavior)
>in <0x00044> System.Data.Common.DbDataAdapter:Fill (System.Data.DataSet 
>dataSet)
>in <0x007b8> ConsoleIntranet.Class1:TestTimestamp ()
>in <0x00015> ConsoleIntranet.Class1:Main (System.String[] args)
>
>Could someone help me how to resolve this issue?
>thanks
>_______________________________________________
>Ce message et les éventuels documents joints peuvent contenir des informations confidentielles.
>Au cas où il ne vous serait pas destiné, nous vous remercions de bien vouloir le supprimer et en aviser immédiatement l'expéditeur. Toute utilisation de ce message non conforme à sa destination, toute diffusion ou publication, totale ou partielle et quel qu'en soit le moyen est formellement interdite.
>Les communications sur internet n'étant pas sécurisées, l'intégrité de ce message n'est pas assurée et la société émettrice ne peut être tenue pour responsable de son contenu.
>  
>
>------------------------------------------------------------------------
>
>Index: mcs/class/System.Data.OracleClient/System.Data.OracleClient/OracleParameter.cs
>===================================================================
>--- mcs/class/System.Data.OracleClient/System.Data.OracleClient/OracleParameter.cs      (revision 47807)
>+++ mcs/class/System.Data.OracleClient/System.Data.OracleClient/OracleParameter.cs      (working copy)
>@@ -258,7 +258,7 @@
>                        OciDataType bindType = ociType;
>                        IntPtr bindValue = IntPtr.Zero;
>                        int rsize = 0;
>-
>+                       Console.WriteLine("Parametre : "+ociType.ToString());
>                        // TODO: handle InputOutput and Return parameters
>                        if (direction == ParameterDirection.Output) {
>                                // TODO: need to figure out how OracleParameter
>@@ -324,9 +324,11 @@
>                                bindSize = 0;
>                        }
>                        else {
>+                               Console.WriteLine("OracleType "+oracleType.ToString());
>                                // TODO: do other data types and oracle data types
>                                // should I be using IConvertible to convert?
>                                if (oracleType == OracleType.DateTime) {
>+                                       Console.WriteLine("DATE!!!");
>                                        string oraDateFormat = connection.GetSessionDateFormat ();
>                                        string sysDateFormat = OracleDateTime.ConvertOracleDateFormatToSystemDateTime (oraDateFormat);
>
>@@ -637,8 +639,11 @@
>                                dbType = DbType.AnsiStringFixedLength;
>                                ociType = OciDataType.Char;
>                                break;
>+                       case OracleType.Timestamp:
>+                               dbType = DbType.DateTime;
>+                               ociType = OciDataType.TimeStamp;
>+                               break;
>                        case OracleType.DateTime:
>-                       case OracleType.Timestamp:
>                        case OracleType.TimestampLocal:
>                        case OracleType.TimestampWithTZ:
>                                dbType = DbType.DateTime;
>Index: mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci/OciDataType.cs
>===================================================================
>--- mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci/OciDataType.cs      (revision 47807)
>+++ mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci/OciDataType.cs      (working copy)
>@@ -43,6 +43,7 @@
>                Blob = 0x71,
>                BFile = 0x72,
>                OciString = 0x9b,
>-               OciDate = 0x9c
>+               OciDate = 0x9c,
>+               TimeStamp = 0xbb
>        }
> }
>Index: mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci/OciParameterDescriptor.cs
>===================================================================
>--- mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci/OciParameterDescriptor.cs   (revision 47807)
>+++ mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci/OciParameterDescriptor.cs   (working copy)
>@@ -67,6 +67,7 @@
>
>                public static OracleType OciDataTypeToOracleType (OciDataType ociType)
>                {
>+                       Console.WriteLine(ociType.ToString());
>                        switch (ociType) {
>                        case OciDataType.VarChar2:
>                                return OracleType.VarChar;
>@@ -120,6 +121,8 @@
>                                return OracleType.VarChar;
>                        case OciDataType.OciDate:
>                                return OracleType.DateTime;
>+                       case OciDataType.TimeStamp:
>+                               return OracleType.Timestamp;
>                        default:
>                                throw new NotImplementedException ();
>                        }
>@@ -180,6 +183,8 @@
>                                return typeof (System.String);
>                        case "OciDate":
>                                return typeof (System.DateTime);
>+                       case "TimeStamp":
>+                               return typeof (System.DateTime);
>                        default:
>                                // FIXME: are these types correct?
>                                return typeof(System.String);
>@@ -242,6 +247,8 @@
>                                        return "OciString";
>                                case OciDataType.OciDate:
>                                        return "OciDate";
>+                               case OciDataType.TimeStamp:
>+                                       return "TimeStamp";
>                                default:
>                                        return "Unknown";
>                        }
>Index: mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci/OciStatementHandle.cs
>===================================================================
>--- mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci/OciStatementHandle.cs       (revision 47807)
>+++ mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci/OciStatementHandle.cs       (working copy)
>@@ -212,8 +212,9 @@
>                                1,
>                                2,
>                                0);
>-
>+               Console.WriteLine("FETCH "+status.ToString());
>                        switch (status) {
>+
>                        case OciGlue.OCI_NO_DATA:
>                                moreResults = false;
>                                break;
>  
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Mono-devel-list mailing list
>Mono-devel-list at lists.ximian.com
>http://lists.ximian.com/mailman/listinfo/mono-devel-list
>  
>




More information about the Mono-devel-list mailing list