DB2 Connector Warning for reading timestamp

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
manojbh31
Premium Member
Premium Member
Posts: 83
Joined: Thu Jun 21, 2007 6:41 am

DB2 Connector Warning for reading timestamp

Post by manojbh31 »

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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Can you verify that the Precision and Scale propertes are set to 22 and 10 respectively?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
manojbh31
Premium Member
Premium Member
Posts: 83
Joined: Thu Jun 21, 2007 6:41 am

Post by manojbh31 »

Yes Ray precision and scale are set to 12 and 10 which are defined as per table definition
asorrell
Posts: 1707
Joined: Fri Apr 04, 2003 2:00 pm
Location: Colleyville, Texas

Post by asorrell »

If you read carefully - he said "22,10" not "12,10".
Andy Sorrell
Certified DataStage Consultant
IBM Analytics Champion 2009 - 2020
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

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!
-craig

"You can never have too many knives" -- Logan Nine Fingers
manojbh31
Premium Member
Premium Member
Posts: 83
Joined: Thu Jun 21, 2007 6:41 am

Post by manojbh31 »

I tried with 22,10 and 12,10 also but still I am getting error.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

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).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

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.
Choose a job you love, and you will never have to work a day in your life. - Confucius
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

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.
Choose a job you love, and you will never have to work a day in your life. - Confucius
Post Reply