Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a set of files to load say 3 files. I first load the STG0 load control table in which I generate batch id and file id and derive the file name (((String)globalMap.get("tFileList_1_CURRENT_FILE")) ). So When I load 3 files in one batch and 2 files in the next batch, the target will look like
BATCh ID | FILE ID | FILE NAME |
1 | 1 | FILE1 |
1 | 2 | FILE2 |
1 | 3 | FILE3 |
2 | 1 | FILE4 |
2 | 2 | FILE5 |
Next I have to load the STG1 table with the data coming from the file along with the batch id and file id generated in the STG0 table. I created a tDBInput pointing to STG0 table as the look up as shown in attached screenshot. But I am not sure how to create a variable to store file name and pass it on to the look up to get batch id and file id. I am new to talend. Any help would be appreciated.
Try the following for your lookup query
"select Id_batch, Id_fil_id, Id_fil_name from stg_0_Id_cntl_nmc where Id_fil_name = '" + ((String)globalMap.get("tFileList_1_CURRENT_FILE")) + "'"
Then add the column Id_fil_name to your tDBInput schema. In the tMap put ((String)globalMap.get("tFileList_1_CURRENT_FILE")) as the "Expr. key" of column "Id_fil_name" in row2.
Let us know how this works out.
I already have the file name in the STG0 table in job1. I just need the batch id and file id from the STG0 table for the respective files and load in STG1 table in job2.
When you mentioned this "on each iteration after file list you can get global variables globalMap.get("tFileList_1_xxx").", do you mean to have tSetGlobalVar after tFileList?
I am not sure I understand. I am new to Talend. I want to use the file names in the job2 to look up on the table STG0 to get batch id and file id.
If there is a look up query then it would be like
Select batch_id,file_id from STG0 where STG0.filename = <filename from job2>
I have attached a screenshot of the job2. I am getting the following error.
Error in the component's properties:The left-hand side of an assignment must be a variable
Syntax error on token "tFileList_1_CURRENT_FILE", invalid AssignmentOperator
Can you please try the following in your lookup query:
"select Id_batch, Id_fil_id, name from stg_0_Id_cntl_nmc where Id_fil_name = '" + ((String)globalMap.get("tFileList_1_CURRENT_FILE")) + "'"
Try the following for your lookup query
"select Id_batch, Id_fil_id, Id_fil_name from stg_0_Id_cntl_nmc where Id_fil_name = '" + ((String)globalMap.get("tFileList_1_CURRENT_FILE")) + "'"
Then add the column Id_fil_name to your tDBInput schema. In the tMap put ((String)globalMap.get("tFileList_1_CURRENT_FILE")) as the "Expr. key" of column "Id_fil_name" in row2.
Let us know how this works out.