Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
BA621858188
Creator
Creator

Context variable not working as expected

Hi All,

I am facing 2 issues with context variable and need your help to resolve the same.

Context variable is of string datatype

expression to store the value in context - context.last_run = TalendDate.formatDate("yyyy-MM-dd", input_row.txndate);

1.Using below query in tmysqlinput component -

"SELECT MAX(date_format(txndate,'%Y-%m-%d'))

FROM table

where substring(`txndate`,1,10) > '"+context.last_run+"'" -- context datatype is string

printing in tjava so in console it is coming as below:

"SELECT MAX(date_format(txndate,'%Y-%m-%d'))

FROM table

where substring(`txndate`,1,10) > '2022-07-29'"

Issue - if no records present in the table for greater than 2022-07-29 then getting an error as below or job ran for already loaded date:

Data truncation: Incorrect date value: '' for column 'loaddate' at row 1 (Snapshot attached)

System.out.println("Load Date is before " + input_row.loaddate);

-> getting value as Null on console

2.I am using below query in tmysqlinput component

select col1,col2 from table1 , table2

on table1.no=table2.no

where substring(date_field,1,10)>'"+context.last_run+"'

Issue - I am getting past records as well like if I have last run as 2022-07-30 still It is retrieving the past data which is less than 2022-07-30. It should fetch the records greater than 2022-07-30 but it is including 2022-07-29 and 2022-07-30 records as well.

I have attached the snapshots of the job.

Thanks in advance.

Labels (2)
0 Replies