Page 1 of 1

How to do conditional commit?

Posted: Wed Dec 29, 2010 1:21 pm
by svhari76
Hi

I have a scenario where i need to commit the database insertion only if certain condition meets.

Eg: i am reading a file line by line and started inserting the same into a table and if the line containe 'ABC' then commit the records inserted sofar and start new insertion.

Any help would be great.

Posted: Wed Dec 29, 2010 1:26 pm
by DSguru2B
Constraint the output link. Only send across the rows that you will commit and then a straight insert into the table.

Posted: Wed Dec 29, 2010 2:07 pm
by svhari76
I hope i should be more clear about my requirement.

I am reading the lines from seq. file and group of lines forms a record in table. If line contains 'ABC' then that is starting of new record, which means we have to commit the group of lines we have inserted so for in table.

Eg: i have 25 lines in my file and first line has ABC so started forming the record, read first line of length100 charcters(fixed),read second line (100chars) append to first line(total 200) in stage and the lenght of column in table is 200 so insert the line with sequence number as 1 and don't commit yet. start reading the 3rd line (100 charas) and 4th line has 'ABC" which means new record.
Now add my 3rd line with seq number 2 to table as second row and commit the transcation.

These sequence numbers 1 and 2 forms record. So either insert both or reject both. So my condition is up on existance of 'ABC' in the line issue commit instruction to DB.

Posted: Wed Dec 29, 2010 2:42 pm
by chulett
You'll need to use the ODBC stage for that since it doesn't care if you don't bind columns into the sql. One link for commit and one for inserts. Add a rollback link if needed.