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

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

tlogrow displaying row correctly and tjavarow printing null

Hi, I have this simple job where I read a line and I need to assign the values to variable through tJavaRow:

 

0683p000009Lzd1.png

 

The query inside the tDBOutput is the following:

"SELECT 
		TEST.EDW_L_LAST_RUN_JOBS.LAST_RUN_DATE,
		TEST.EDW_L_LAST_RUN_JOBS.LAST_SESSION_ID
FROM	TEST.EDW_L_LAST_RUN_JOBS
where TEST.EDW_L_LAST_RUN_JOBS.PRC_NAME = 'SERVICE' "

and if I run it directly on the DB it works. In fact, tLogRow component prints the correct values of the row it's reading. The problem is that in tJavaRow I do this:

 

context.last_run_date = input_row.LAST_RUN_DATE;
context.session_tag = input_row.LAST_SESSION_ID;
System.out.println("Session tag1 " + row2.LAST_SESSION_ID + " last run1 " + row2.LAST_RUN_DATE);
System.out.println("Session tag " + context.session_tag + " last run " + context.last_run_date);

and all the 4 values are printed null. I've tried both using input_row and row2 and with assignment, but it isn't working. Where could the problem be?

Labels (3)
1 Solution

Accepted Solutions
fdenis
Master
Master

in the second case, you fill a dataset of 4 columns with a dataset of 2 columns.
what is the definition of your row1 data link?

View solution in original post

8 Replies
Anonymous
Not applicable
Author

So, I've changed the query adding the two other columns of the table I didn't add, prc_name and job_name:

"SELECT
		TEST.EDW_L_LAST_RUN_JOBS.PRC_NAME, 
		TEST.EDW_L_LAST_RUN_JOBS.JOB_NAME,
		TEST.EDW_L_LAST_RUN_JOBS.LAST_RUN_DATE,
		TEST.EDW_L_LAST_RUN_JOBS.LAST_SESSION_ID
FROM	TEST.EDW_L_LAST_RUN_JOBS
where TEST.EDW_L_LAST_RUN_JOBS.PRC_NAME = 'SERVICE' "

I've decided to add them because after adding the "print header" option, this is what the output looked like:

0683p000009Lzgi.png

That means that 1900-01-01 00:00:00.0 was printed as "prc_name" and not as "last_run_date". 

Why does it print even the columns I didn't ask for? How does it work?

 

 

fdenis
Master
Master

setting context value Durring execution is not a good Idea.
you can use globalMap if you need some.
why dont you use:
System.out.println(input_row.LAST_RUN_DATE.toString());
in your tJavaRow?

fdenis
Master
Master

1900-01-01 00:00:00.0 is the printing value for null date.
Anonymous
Not applicable
Author


@fdenis wrote:
1900-01-01 00:00:00.0 is the printing value for null date.

No, the date is correct, is the date I have on the DB. I was wondering why, if I don't put all the fields in the query, it prints it as another field. Why does it keeps even the fileds I didn't ask for?

fdenis
Master
Master

to fill tDbInput output fields, Talend use the order of fields returned by the database.
is your tLog in Table Mode?
what does it print?
Anonymous
Not applicable
Author


@fdenis wrote:
to fill tDbInput output fields, Talend use the order of fields returned by the database.
is your tLog in Table Mode?
what does it print?

In table mode it prints this:

0683p000009Lzgn.png

and this is if, in the query, I consider the other two field (prc_name and job_name) that I do not need for my operations. 

If, instead, in the query I specify just last_run_date and last_session_id in the "select" statement, it prints the same 4 fields, but with the value of "last run date" in the place of the value of "prc_name" and the value of "last session id" in the place of the value of "job name". Like this:

0683p000009Lzgs.png

Why does it consider prc_name and job_name if I didn't specify them in the query? I don't need this fields, why do I have to consider them even if I don't want to?

fdenis
Master
Master

in the second case, you fill a dataset of 4 columns with a dataset of 2 columns.
what is the definition of your row1 data link?
RPurwosaputro1645587534

0695b00000Wv2zNAAR.pngfacing the same problem but the query want to retrieve maximum value of a column, but return null using tJava component to assign query result to context

 

query :

"select max(dt_offset)

from table_log

where job_name = job_name and status=1"

 

tJava component :

context.dt_offset = row_input.dt_offset

 

Where could the problem be?