Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Reading TimeStampTZ doesn't not assign System.DateTime.Kind

586469Jul 4 2007
I have an issue where I can assign a UTC DateTime value to a record, but ODP.Net doesn't assign the System.DateTime.Kind property as the value is read back from the database. While the tick value is accurate, the kind is marked as Unspecified whereas it should be UTC.

I believe the bug is in the following location:

Assembly: Oracle.DataAccess.dll
Class: Oracle.DataAccess.Types.DateTimeConv
Method: public static unsafe DateTime GetDateTime(OpoTSValCtx* pValCtx, OracleDbType oraType, bool bCheck)

This method contains a test that (oraType == OracleDbType.TimeStampTZ) yet it doesn't use the System.DateTime constructor to specify the kind:

The current implementation is:

DateTime time = new DateTime(pValCtx.m_year, pValCtx.m_month, pValCtx.m_day, pValCtx.m_hour, pValCtx.m_minute, pValCtx.m_second);

This line of code is from version 10.2.0.100, but I have also checked 10.2.0.2.21 which has the same problem.

This would be fixed by using the following constructor (where the type is TimeStampTZ):

DateTime time = new DateTime(pValCtx.m_year, pValCtx.m_month, pValCtx.m_day, pValCtx.m_hour, pValCtx.m_minute, pValCtx.m_second, System.DateTimeKind.Utc);
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 1 2007
Added on Jul 4 2007
0 comments
717 views