How to do conditional commit?

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
svhari76
Participant
Posts: 48
Joined: Tue Nov 16, 2010 5:04 pm

How to do conditional commit?

Post 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.
Hari
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Constraint the output link. Only send across the rows that you will commit and then a straight insert into the table.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
svhari76
Participant
Posts: 48
Joined: Tue Nov 16, 2010 5:04 pm

Post 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.
Hari
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply