Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to rollback a commited delete Query

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Rameshkumar.R

New User


Joined: 15 May 2008
Posts: 9
Location: chennai

PostPosted: Tue Jul 28, 2009 11:04 am    Post subject: How to rollback a commited delete Query
Reply with quote

Hi,
I deleted wrong table with commit is there any way to restore the deleted data ?

Thanks in advance
Back to top
View user's profile Send private message

sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1013
Location: India

PostPosted: Tue Jul 28, 2009 12:01 pm    Post subject:
Reply with quote

Hi,

I hope this incident happened in Development.
Contact your DBA he will do the restoring part...

Sushanth
Back to top
View user's profile Send private message
Rameshkumar.R

New User


Joined: 15 May 2008
Posts: 9
Location: chennai

PostPosted: Tue Jul 28, 2009 12:07 pm    Post subject:
Reply with quote

Hi,
We have option of ROLLBACK with SAVEPOINT
I dont know how to execute it ?
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1013
Location: India

PostPosted: Tue Jul 28, 2009 12:36 pm    Post subject:
Reply with quote

Ramesh,

ROLLBACK TO SAVEPOINT comes into picture only for LUW(logical unit of work) not for a particular time frame.

Example of savepoints(courtesy : DB2 V9 Application programing & SQL Guide)
i.e., it goes to savepoint B
Code:
EXEC SQL SAVEPOINT A;
...
EXEC SQL SAVEPOINT B;
...
EXEC SQL ROLLBACK TO SAVEPOINT;


If you give
Code:
EXEC SQL ROLLBACK TO SAVEPOINT A;

It goes to SAVEPOINT A

You have to code this in a program.

By the way, How did you delete the data ? using a program or spufi or etc.,


Sushanth
Back to top
View user's profile Send private message
Rameshkumar.R

New User


Joined: 15 May 2008
Posts: 9
Location: chennai

PostPosted: Tue Jul 28, 2009 12:39 pm    Post subject: Its through SPUFI
Reply with quote

I deleted through SPUFI
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10274
Location: italy

PostPosted: Tue Jul 28, 2009 12:57 pm    Post subject: Reply to: How to rollback a commited delete Query
Reply with quote

when these events happen, letting time go by worsen the whole thing

the data/table(*) is lost, and you lost about two hours in recovering the situation

talk to Your DBA' s

(*)
some data rows if You issued a DELETE
the table itself if You issued a DROP
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1013
Location: India

PostPosted: Tue Jul 28, 2009 1:27 pm    Post subject:
Reply with quote

Ramesh,

SAVEPOINT doesn't work in spufi. But you can use COMMIT & ROLLBACK statements like the following.
Code:
SELECT * FROM BOBT1.COUNTRY;       
INSERT INTO BOBT1.COUNTRY         
       VALUES (250,'PARIS','B-13');
SELECT * FROM BOBT1.COUNTRY;       
ROLLBACK;                         
SELECT * FROM BOBT1.COUNTRY;       
commit;                           


And do remember AUTOCOMMIT is usually set to YES in spufi ? set it to NO, so after executing the query DB2 will ask whether you want to commit, rollback or defer.

Sushanth
Back to top
View user's profile Send private message
Rameshkumar.R

New User


Joined: 15 May 2008
Posts: 9
Location: chennai

PostPosted: Tue Jul 28, 2009 1:53 pm    Post subject: Thanks a lot Bobby
Reply with quote

Thanks a lot Bobby
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us