System.TimeSpan does not match Oracle 9i INTERVAL DAY TO SECOND data type (324577)
The information in this article applies to:
- Microsoft ADO.NET (included with the .NET Framework)
- Microsoft ADO.Net 2.0
This article was previously published under Q324577
This article refers to the following Microsoft .NET Framework Class Library namespace:
SYMPTOMS
When you try to compare a string that is derived from a System.TimeSpan data type to an Oracle INTERVAL DAY TO SECOND data type, you may receive the following error message:
ORA-01867: the interval is invalid
CAUSE
When an Oracle 9i INTERVAL DAY TO SECOND data type is returned to the Microsoft .NET Framework, it is converted to a System.TimeSpan data type. This problem occurs because System.TimeSpan uses the "dd.hh:mm:ss" format (with a period after "dd"), and the Oracle 9i INTERVAL DAY TO SECOND data type uses the "dd hh:mm:ss" format (without a period after "dd"). Because the data types do not match, you cannot compare the strings of these data types.
RESOLUTION
To resolve this problem, use one of the following methods:
- Build your own formatted string from System.TimeSpan as follows:
string value = String.Format("{0} {1}:{2}:{3}.{4}", ts.Days, ts.Hours, ts.Minutes, ts.Seconds. ts.Milliseconds)
- Bind System.TimeSpan as OracleType.IntervalDayToSecond, and then avoid the conversion.
STATUSThis behavior is by design.
Modification Type: | Major | Last Reviewed: | 3/13/2006 |
---|
Keywords: | kbOracle kbprb kbSystemData KB324577 kbAudDeveloper |
---|
|