[resolved] how to control commit or rollback in line level
Hi, I want to do something normal like insert two outputs of a tMap into two differents tables, but I want to control commit or rollback for every line of the file(if there is no reject for both the two tables, I commit, if not, rollback ), not at the end of all lines. Is this possible? If yes, I should based on which condition to know if there is no rejects for both two tables? Thanks in advance.
sure. use an iterate link to process one row at a time. so, tFileInputDelimited--row-->tFlowToIterate---iterate--->tFixedFlowInput---row->tMap in the tFixedFlowInput, retireve the column values that the tFlowToIterate stores from the globalMap. so if you have a column "some_data" in the row1 input to the tFlowToIterate, it will be in the global map with the key "row1.some_data". The tFixedFlowInput will (by default) output one row per iteration, and feed it to the rest of your job.
Thanks a lot for your help. But I still have a question, if I do something like this (see shotscreen), what should be the if conditions? I tried the conditions: for commit: (Integer)globalMap.get("tMSSqlOutput_1_NB_LINE_REJECTED")<=0 && (Integer)globalMap.get("tMSSqlOutput_2_NB_LINE_REJECTED")<=0 for rollback (Integer)globalMap.get("tMSSqlOutput_1_NB_LINE_REJECTED")>0 || (Integer)globalMap.get("tMSSqlOutput_2_NB_LINE_REJECTED")>0 But it does not work.
Hi
As John said, iterate each row and pass each row to child job, the job design should be:
parent job:
tFileInputDelimited--main--tFlowToIterate--tRunJob_1
child job:
tMssqlConnection
|
onsubjobok
|
tFixedFlowInput--main--tMap---main--tMssqloutput_1
---main--tMssqlOutput_2
---onsubjobok---tMssqlcommit
---onsubjoberror--tMssqlRollback.
On tRunJob_1: call the child job and pass each row to child job, uncheck the box 'die on error'
on tMssqloutput_1 and tMssqloutput_2: check the box 'die on error'
Best regards
Shong
Thanks so much.
I have a last question, in the parent job in tFlowToIterate I store a value into the globalMap, and in the child job I can't retrive it in the tFixedFlowInput. I suppose that's because the parent job and child job don't share the same globalMap. So how can I get the value in the child job? I checked "transmit whole context" in tRunJob.