cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Inserting timestamp string to DB2 database table

ricardoTyson
New Contributor II

Hello, I am having trouble with writing to a db2 database table using the jdbc generic insert, or being more specific writing a timestamp format string to a timestamp column.
I have to read from a csv fle and insert the rows into a db2 database table
image

I can perfectly do so by skipping the timestamp column but that will cause the field in the table record to take the current timestamp value(which obviously is not the intended outcome)
image
when I try it with the date value i get the next error โ€œBatch failure. The batch was submitted, but at least one exception occurred on an individual member of the batchโ€, I only get this error when including the date in the mapper output to the jdbc insert.

the initial date&time string is in his format: โ€œM/DD/YYYY HH.MMโ€ and I format it in two steps(mappers)
first: Date.parse($[โ€˜Date & Timeโ€™]).toLocaleDateTimeString() OUTPUT=>โ€œ2018-08-21T16:48:00.000โ€
second: ($DATE_PROCESSED.slice(0,10)+โ€œ-โ€+$DATE_PROCESSED.slice(11).replaceAll (โ€œ:โ€,โ€œ.โ€)+โ€œ000โ€).toString() OUTPUT=>โ€œ2018-08-21-16.48.00.000000โ€ this is the format(TIMESTAMP) that is stored in the database but for some reason the insert still fails only when I include it in the mapper and I have tested the same string that the mapper gives me by inserting through query and it works fineโ€ฆ I donโ€™t know what could be messing in the middle that I am not seeingโ€ฆ Iโ€™d appreciate
any insights you can have on the way I am managing things.
THANK YOU.

0 REPLIES 0