IT Community - Software Programming, Web Development and Technical Support

Savepoint in Sql Transaction

This is a discussion on Savepoint in Sql Transaction within the Database Support forums, part of the Web Development category; Hi all, Just want to share the Concept of using Savepoint in DML Statements (transactional SQL). Example: CREATE TABLE TEST_SAVEPT ( ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > Database Support

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 03-01-2007, 03:38 AM
Murali Murali is offline
D-Web Master
 
Join Date: Feb 2007
Location: India-Chennai.
Posts: 386
Murali is on a distinguished road
Send a message via AIM to Murali
Default Savepoint in Sql Transaction

Hi all,

Just want to share the Concept of using Savepoint in DML Statements
(transactional SQL).

Example:

CREATE TABLE TEST_SAVEPT
(
ID NUMBER PRIMARY KEY,
NAME VARCHAR2(100)
);

INSERT INTO TEST_SAVEPT VALUES (1,'Test1');
INSERT INTO TEST_SAVEPT VALUES (2,'Test2');
INSERT INTO TEST_SAVEPT VALUES (3,'Test3');
INSERT INTO TEST_SAVEPT VALUES (4,'Test4');
INSERT INTO TEST_SAVEPT VALUES (5,'Test5');
SAVEPOINT S_1;
INSERT INTO TEST_SAVEPT VALUES (6,'Test6');
INSERT INTO TEST_SAVEPT VALUES (7,'Test7');
INSERT INTO TEST_SAVEPT VALUES (8,'Test8');
INSERT INTO TEST_SAVEPT VALUES (9,'Test9');
INSERT INTO TEST_SAVEPT VALUES (10,'Test10');
SAVEPOINT S_2;
INSERT INTO TEST_SAVEPT VALUES (11,'Test11');
INSERT INTO TEST_SAVEPT VALUES (12,'Test12');
INSERT INTO TEST_SAVEPT VALUES (13,'Test13');
INSERT INTO TEST_SAVEPT VALUES (14,'Test14');
INSERT INTO TEST_SAVEPT VALUES (15,'Test15');

ROLLBACK TO S_2;
COMMIT;

SELECT * FROM TEST_SAVEPT;

ID NAME
1 Test1
2 Test2
3 Test3
4 Test4
5 Test5
6 Test6
7 Test7
8 Test8
9 Test9
10 Test10

Like this data can be rollbacked to a particular limit(on basis of the specified Savapoint).

The Values inserted after the savepoint S_2 alone will be rollbacked from the table.
__________________
-Murali..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Transaction Scope in DotNet using C#. S.Vinothkumar C# Programming 52 09-22-2007 01:15 AM
What are different transaction levels in SQLSERVER? oxygen Database Support 1 07-26-2007 04:16 AM
How automatically backup of Transaction log for specific Database oxygen Database Support 1 07-24-2007 05:31 AM
What are the Page level transaction and class level transaction? H2o Other Web Programming Languages 1 07-20-2007 02:48 AM
How to enforce Transaction concept (ie: commit,rollback ) from .net web application kingmaker C# Programming 0 07-16-2007 11:15 PM


All times are GMT -7. The time now is 06:31 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0