I have a column in old oracle DB in which values are present as "10/27/2014 10:14:26" and i want it to migrate in my new DB in 2 column viz. date and time. I have written the following code in tMap
TalendDate.parseDate("MM/dd/yyyy'T'HH:mm:ss'Z'","row1.BLOCK_DATE")
but on running the job i am getting following excepition:
Exception in component tMap_1
java.lang.RuntimeException: java.text.ParseException: Unparseable date: "row1.BLOCK_DATE"
at routines.TalendDate.parseDate(TalendDate.java:864)
at routines.TalendDate.parseDate(TalendDate.java:808)
at zain.transfer_0_1.transfer.tOracleInput_3Process(transfer.java:999)
at zain.transfer_0_1.transfer.runJobInTOS(transfer.java:1534)
at zain.transfer_0_1.transfer.main(transfer.java:1391)
Caused by: java.text.ParseException: Unparseable date: "row1.BLOCK_DATE"
at java.text.DateFormat.parse(DateFormat.java:357)
at routines.TalendDate.parseDate(TalendDate.java:850)
... 4 more
someone please help me on this.
Remove double quotes and pass the column name as it is, it will work. use like this
TalendDate.parseDate("MM/dd/yyyy'T'HH:mm:ss'Z'",row1.BLOCK_DATE)
Related
I am a SQL DBA trying to get some information in Cognos.
The column name is [Packingdate] column.
In order to retrieve last 7 days of packing data information I use the below.
where [Packingdate] >_add_days( current_date, -7 ) -This is working fine.
However when i tried to get November month data I tried the below
[Packingdate] between '2021-11-01' and '2021-11-30'
It is giving me the below error
RQP-DEF-0177 An error occurred while performing operation 'sqlPrepareWithOptions' status='-126'.
Ami missing something?
Remove the quotes:
[Packingdate] between 2021-11-01 and 2021-11-30
When dealing with date or datetime data, YYYY-MM-DD (without quotes) is the format Cognos understands.
I have Excel data and trying to insert the data into MongoDB using Talend Big Data for Open Studio. This is my job,
tFileInputExcel --> tMap --> tMongoDBOutput
In excel sheet, i have a date value column in this format 7/13/2017(MM/dd/yyyy) as string type and I am trying to insert this column value as ISO format ISODate("2017-07-13T00:00:00.000Z") in MongoDB.
This is my Job:
tFileInputExcel:
tMap:
tMongoDBOutput:
When execute this job, I'm getting the below error.
Error:
When i change the parse format like this TalendDate.parseDate("MM/dd/yyyy",row1.ClosingDate) , I'm getting SimpleDateFormat error. Simple Date Format Error
How to resolve this issue?
you can do simply if you mongodb column schema is date:
TalendDate.parseDate("MM/dd/yyyy",row3.newColumn)
That will automatically convert the date in the date model that your mongoDB column have.
You can change in your schema in Talend the date Model like "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'".
This is a very common mistake doing in reading data without understanding the underlying data types.
I have blogged about this especially for Talend: https://www.tobiasmaasland.de/2017/07/20/using-date-in-talend-etl-jobs/
But let me explain a bit.
Sometimes Excel tries to convert data in the cell even if one might think the cell type is set to String. Insted, it is set to Date. As such, no conversion is needed and the type needs to be Date in the input component.
If it is a String and an error occurs, the the structure of the String is either not the same everywhere or some cells are empty (null). So you might be lucky with
TalendDate.parseDate("MM/dd/yyyy", (row1.ClosingDate == null), "01/01/1970", row1.ClosingDate)
I just assumed you might want to use a placeholder date insted of having null.
This heavily depends on the actual data type in the cells, if every cell has the same data type and if all the data is formatted correctly.
To sum up one of the facts in my blog post: Don't use String for dates. Use Date for dates in Excel. It makes everything easier.
I have a talend solution where inside it rests a tMap --> tPostgreSQLOutput.
Inside the schema is a integer(key field) and a Date(Timestamp) in the format of "dd-MM-yyyy HH:mm:ss". The intent is to update the date field with the current time/date (Timestamp).
the date is set with this talend function call in the tMap:
TalendDate.parseDate("yyyy-MM-dd HH:mm:ss", TalendDate.getDate("yyyy-MM-dd HH:mm:ss"))
I have confirmed the date(timestamp) format, and confirmed that the timestamp data type in the PostgreSQL database. However, I'm getting this error upon runtime:
Batch entry 0 UPDATE "bitcoin_options" SET "last_notified" = 2017-04-08 12:02:40.000000 -05:00:00 WHERE "id" = 3 was aborted. Call getNextException to see the cause.
I took the query it errored and manually ran it into PostgreSQL. I got this response:
ERROR: syntax error at or near "11"
LINE 1: ...bitcoin_options" SET "last_notified" = 2017-04-08 11:53:11.0...
^
Again, I checked the format, the datatype, and compared them against other tables and their UPSERTS. same format. same datatype.
In addition, I attempted to add a second space between date and time, with no avail.
UPDATE 1
I updated the tMap output to:
TalendDate.getCurrentDate();
and got the same error.
Thanks
UPDATE 2
Here's my layout for Talend:
I figured it out. after much trial and error.
The tPostgresSQLCommit x3 was redundant. When I removed the first two and placed just one, it gave me the proper output.
LESSONS LEARNED: You only need 1 commit.
Notice your timestamp is not properly formatted:
UPDATE "bitcoin_options" SET "last_notified" = '2017-04-08 12:02:40.000000 -05:00:00' WHERE "id" = 3
It's missing the single quotes surrounding the timestamp. If you add those you should be good to go.
I am using talend to retrieve data from Oracle DB. I am using tOracleRow to select the data and I am parsing the resultset using tParseRecordSet component. The result set contains date fields and I am getting error on parsing the date filed. Below is my error.
Exception in component tParseRecordSet_1
java.lang.RuntimeException: Unparseable date: "2000-01-01 00:00:00.0"
at routines.system.ParserUtils.parseTo_Date(ParserUtils.java:245)
at data.extract_0_1.Extract.tFileInputExcel_1Process(Extract.java:1821)
at data.extract_0_1.Extract.tOracleConnection_1Process(Extract.java:417)
at data.extract_0_1.Extract.runJobInTOS(Extract.java:2427)
at data.extract_0_1.Extract.main(Extract.java:2292)
I tried using date format - "yyyy-MM-dd'T'HH:mm:ss.ss.S", but still the error exits. Please advise.
Thanks
Try to use tOracleInput to select data from DB. You don't need to use tParseRecordSet in this case.
In schema for 'Date' type column use "yyyy-MM-dd HH:mm:ss.ss" in Date pattern.
I had the same problem and I have resolved changed the oracle select transforming the date field in string using to_char
I have Greenplum input, TMAP and Greenplum output as my job design.
I have a Postgres input(Greenplum Input) wherein I using this postgres query:
to_char(to_date(EI.LAST_UPDATE_DATE,'yyyy-mm-dd'),'DD-MON-YYYY')
I link this Postgres input (Greenplum Input) to Tmap wherein I take tmap input: LAST_UPDATE_DATE as Date and pattern as "yyyy-MM-dd HH:mm:ss". On my tmap output I map a similar target output Greenplum with similar column and set the date and pattern as same ie Date and pattern as "yyyy-MM-dd HH:mm:ss". I link this tmap to a greenplum output.
I am getting an error of GreenplumInput:
Bad value for type timestamp 11-NOV-2008.
How do I sort this error? Do I take the date input as string and then convert it to date? I tried it in tmap itself by taking tmap output as talendparsedate to that column, but it shows unparseable date.
The error message mentions this as timestamp input
11-NOV-2008
Which dies not match your pattern:
to_date(EI.LAST_UPDATE_DATE,'yyyy-mm-dd')
Either change the input to:
2008-11-11
Or the pattern in your function to:
to_date(EI.LAST_UPDATE_DATE,'DD-MON-YYYY')