View previous topic :: View next topic
|
Author |
Message |
Shanu.sukoor
New User
Joined: 31 Jan 2006 Posts: 32 Location: India
|
|
|
|
Hi,
I have written a program which inserts rows. The entire program works in a loop.So each time it goes into the loop rows will be inserted in three tables.
I have to roll back all the rows I have inserted through the current execution of the program, if any sql errors happens during execution.
Could you please explain me how I can do this. For this I have to set commit point (Synch point) at the beginning of the program and roll back the changes till that point. If you have ever done this, please help me.
Thank you,
Shanu |
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
hi
i dont think u need to set a commit at the beginning of the loop ... just do a normal rollback if any error happens within the loop .... |
|
Back to top |
|
|
Shanu.sukoor
New User
Joined: 31 Jan 2006 Posts: 32 Location: India
|
|
|
|
Will that roll back all the rows inserted throgh the program? I think that will roll back the insert done at that point of time. Please corerct me if I am wrong. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Hi Shanu,
A rollback will affect every insert done in that Logical Unit of Work. The LUW started at the first DB operation (or the last syncpoint) and will continue until the program ends or issues a rollback (or syncpoint).
Does that answer your question?
Bill |
|
Back to top |
|
|
Shanu.sukoor
New User
Joined: 31 Jan 2006 Posts: 32 Location: India
|
|
|
|
Thanks.... I was confused about where the LUW starts and now I am clear. |
|
Back to top |
|
|
adarsha
New User
Joined: 28 Dec 2006 Posts: 8 Location: Noida,Delhi
|
|
|
|
Shanu.sukoor wrote: |
Hi,
I have written a program which inserts rows. The entire program works in a loop.So each time it goes into the loop rows will be inserted in three tables.
I have to roll back all the rows I have inserted through the current execution of the program, if any sql errors happens during execution.
Could you please explain me how I can do this. For this I have to set commit point (Synch point) at the beginning of the program and roll back the changes till that point. If you have ever done this, please help me.
Thank you,
Shanu |
hi shanu,
There are lots of ways to do the roll back. first thing is that whether your program is file driven or Database Driven.
if its file drive once again whether its Vsam, Sequential, GSAM or any type of file driven.
File Driven roll Back,
if your program is reading any above mentioned type of files then you can take the check point of each record before populating the DB relations. After updating any DB obiously you check the SQL codes. there you can fix the logic whether you can rooll back is done to any destination files.
If you want to retrieve all the rows inserted then you need to commit each and every record.
i think its not a friendly logic under that situation when you need to handle lacks of record (usually).
let me know if you are cleared with this or not!!!! |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
adarsha wrote: |
There are lots of ways to do the roll back. first thing is that whether your program is file driven or Database Driven.
if its file drive once again whether its Vsam, Sequential, GSAM or any type of file driven.
File Driven roll Back,
if your program is reading any above mentioned type of files then you can take the check point of each record before populating the DB relations. After updating any DB obiously you check the SQL codes. there you can fix the logic whether you can rooll back is done to any destination files.
If you want to retrieve all the rows inserted then you need to commit each and every record.
i think its not a friendly logic under that situation when you need to handle lacks of record (usually).
let me know if you are cleared with this or not!!!! |
I am not clear with this???? |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
Back to top |
|
|
|