Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi, I have this simple job where I read a line and I need to assign the values to variable through tJavaRow:
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?
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:
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 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 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:
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:
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?
facing 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?