Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I want to stock a date (timestamp) in a variable to use it late in a query (PostgreSQL). so i used tsetGlobalVar and then in my query i used this query :
WHERE SX.\"Date\" = "+TalendDate.parseDate("yyyy-MM-dd'T'HH:mm:ss", (String)globalMap.get("row2.DateKey"))+"
And i get a java.lang.NullPointerException Error
I think the problem is in parsing Timestamp, please can anyone help me
Hi, maybe you have to check before if your date is null ?
Thank you for your reply my date is not null
as i see you set your value to "MaxDate", so you try to parse a string("MaxDate") as a date try this instead : row2.MaxDate without the double quote in your tsetglobalvar value
Send Me Love and Kudos
(String)globalMap.get("row2.DateKey")) don't exist in your globalvar : (String)globalMap.get("DateKey")) exist.
So first check wich field contain the date you want in the row2 : then in your tsetglobalvar : you set a key here "DateKey" and (the value row2.(the field of the date) without double quote).
then you can call DateKey : (String)globalMap.get("DateKey")). Don't use parseDate you can already send a string in the query.
Thank you for you reply i've updated my job as you asked me to do,
unfortunately, it doesn't work because talend is parsing data from timestamp to date, Now i get this error :
Syntaxe error near "Mar"
My date is : 2021-03-17T11:40:54
Talend reading it as : Wed Mar 17
Please can you help me with that, FYI : im using postgresql
ok, so in your row 2 your date field is a date type or a string ? IF i'ts a date set "yyyy-MM-dd'T'HH:mm:ss" in the pattern of the date on the suiviXML component schema.
The tDbinput already parse the date with a pattern so you can put your own directly on his schema and it will overwrite it
Yes it's already set as a date and pattern is like you said
Yes