This content has been marked as final. Show 3 replies
What TypeMode is in use for the datastore? How is the column defined in the TT database? What is the SQL statement being executed? What value is being passed to setDate()/setTimestamp()?
I am firing simple insert statement.
Column type is Date
The following statement gives data truncation error
pstmtCDRData.setTimestamp(3, new Timestamp(new Date().getTime()));
while following does not
pstmtCDRData.setDate(3,new java.sql.Date(new Date().getTime()));
This is because an Oracle Date (and a TimesTen DATE in Oracle TypeMode) includes a time valuebut the precision of the time value is only down to seconds. A TIMESTAMP has a precison down to microseconds. When one tries to insert such a value into a DATE column then the value has to be truncated (loss of the fractional seconds part). The issue here appears to be an API (JDBC or ODBC) issue since performing such an INSERT in SQL succeeds with no error:
CREATE TABLE Z(D1 DATE);
INSERT INTO Z VALUES (DATE '2008-01-01');
succeeeds as does
INSERT INTO Z VALUES(TIMESTAMP '2008-01-01 12:00:00.123456');
INSERT INTO Z VALUES(TT_SYSDATE);
Since TimesTen's objective is to be as compatible as possible with Oracle I would consider this a bug. I will raise a bug report for this. In the meantime the only workaround is to use setDate which should work correctly with both Oracle and TimesTen (and is really what you should be using anyway since it is a DATE column).