DB2 Connector Warning for reading timestamp
Moderators: chulett, rschirm, roy
DB2 Connector Warning for reading timestamp
Hi, I am using DB2 Connector to read data from DB2 table. there is column with timestamp (12,10) in table when I am reading this field using DB2 Connector stage I am getting below error.
When reading database column DATETIME(fraction=10) into column DATETIME(fraction=0), truncation, loss of precision or data corruption can occur.
Before posting I did search similar issue, but the solutions provided in other posts is not working. And I cannot use CAST function to change to VARCHAR. I have turned off Fail in size mismatch. I am using timestamp (12,10) in db2 connector stage.
Please help.
When reading database column DATETIME(fraction=10) into column DATETIME(fraction=0), truncation, loss of precision or data corruption can occur.
Before posting I did search similar issue, but the solutions provided in other posts is not working. And I cannot use CAST function to change to VARCHAR. I have turned off Fail in size mismatch. I am using timestamp (12,10) in db2 connector stage.
Please help.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Pardon my ignorance of all things DB2 but what exactly would a TIMESTAMP(12,10) be? I could understand TIMESTAMP(10) or maybe even TIMESTAMP(12) but I can't find anything online where DB2 supports anything other than just TIMESTAMP... no mention of precision or 'fraction' needed.
Thanks for the opportunity to learn me something today!
Thanks for the opportunity to learn me something today!
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
DataStage's understanding is governed by Precision and Scale. Precision is the total number of characters, while Scale is the number of fractional seconds.
A timestamp with no fractional digits is 19 characters long. Thus, for ten fractional digits, you really need 30,10 (not 22,10).
A timestamp with no fractional digits is 19 characters long. Thus, for ten fractional digits, you really need 30,10 (not 22,10).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
According to the DB2 docs:
A timestamp is a six-part or seven-part value (year, month, day, hour, minute, second, and optional fractional second) with an optional time zone specification, that represents a date and time.
The time portion of a timestamp value can includes a specification of fractional seconds. The number of digits in the fractional seconds portion is specified using an attribute in the range from 0 to 12 with a default of 6.
If you want a timestamp with a specified precision, the special register can be referenced as CURRENT TIMESTAMP(integer), where integer can range from 0 to 12. The default precision is 6.
A timestamp is a six-part or seven-part value (year, month, day, hour, minute, second, and optional fractional second) with an optional time zone specification, that represents a date and time.
The time portion of a timestamp value can includes a specification of fractional seconds. The number of digits in the fractional seconds portion is specified using an attribute in the range from 0 to 12 with a default of 6.
If you want a timestamp with a specified precision, the special register can be referenced as CURRENT TIMESTAMP(integer), where integer can range from 0 to 12. The default precision is 6.
Choose a job you love, and you will never have to work a day in your life. - Confucius
Actual queries:
db2 => SELECT CURRENT TIMESTAMP FROM SYSIBM.SYSDUMMY1
2016-03-05-09.25.17.473106
db2 => SELECT CURRENT TIMESTAMP(12) FROM SYSIBM.SYSDUMMY1
2016-03-05-09.25.24.036628000000
db2 => SELECT CURRENT TIMESTAMP(12,10) FROM SYSIBM.SYSDUMMY1
SQL0104N An unexpected token "," was found following "CURRENT TIMESTAMP(12".
Expected tokens may include: ")". SQLSTATE=42601
-- no such thing within DB2
Another thing I noticed on DB2 10.5 is that no matter how many times I ran the above query with (12), the last 6 fractional seconds were always zeros.
db2 => SELECT CURRENT TIMESTAMP FROM SYSIBM.SYSDUMMY1
2016-03-05-09.25.17.473106
db2 => SELECT CURRENT TIMESTAMP(12) FROM SYSIBM.SYSDUMMY1
2016-03-05-09.25.24.036628000000
db2 => SELECT CURRENT TIMESTAMP(12,10) FROM SYSIBM.SYSDUMMY1
SQL0104N An unexpected token "," was found following "CURRENT TIMESTAMP(12".
Expected tokens may include: ")". SQLSTATE=42601
-- no such thing within DB2
Another thing I noticed on DB2 10.5 is that no matter how many times I ran the above query with (12), the last 6 fractional seconds were always zeros.
Choose a job you love, and you will never have to work a day in your life. - Confucius