If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > transactions

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-14-06, 04:03
nelapsi nelapsi is offline
Registered User
 
Join Date: Dec 2004
Posts: 43
transactions

how can i start transaction?
before DB2 I have using PostgresSQL and i just do
Code:
CREATE table t111(id integer);
START TRANSACTION ;
insert into t111 values(1);
insert into t111 values(2);
insert into t111 values(3);
select count(*) from t111;
 count
-------
     3
(1 row)

rollback;
select count(*) from t111;
 count
-------
     0
(1 row)
in db2 i do
Code:
CREATE table t111(id integer)
commit
insert into t111 values(1)
insert into t111 values(2)
insert into t111 values(3)
select count(*) from t111

1
-----------
          3
rollback
select count(*) from t111

1
-----------
          3
that I must to do to get real transaction?
PS sorry for my english
Reply With Quote
  #2 (permalink)  
Old 02-14-06, 06:16
przytula przytula is offline
Registered User
 
Join Date: Nov 2004
Posts: 374
autocommit

if executed from command line
put all statements in a file
execute with db2 -tv +c -f filename
or see db2 ? options or see Command line processor options in infocenter
__________________
Best Regards, Guy Przytula
DB2/ORA/SQL Services
DB2 DBA & Advanced DBA Certified
DB2 Dprop Certified
http://users.skynet.be/przytula/dbss.html
Reply With Quote
  #3 (permalink)  
Old 02-14-06, 06:25
grahammartin grahammartin is offline
Registered User
 
Join Date: Apr 2005
Posts: 41
There isn't an explicit TRANSACTION in DB2, but there is:

db2 "create table g1 (col1 int)"
db2 "insert into g1 values(1)"
db2 "commit"
db2 +c "insert into g1 values(2)"
db2 "rollback"

in the above scenario, onlt the value of 1 will be in the table

Within SQL/PL in DB2 Stored Procedures, you can make use
of the SAVEPOINT, COMMIT, ROLLBACK commands.

Graham Martin
http://www.ibm.com/software/data/db2/migration/
Reply With Quote
  #4 (permalink)  
Old 02-14-06, 07:03
gardenman gardenman is offline
Registered User
 
Join Date: Apr 2004
Posts: 54
By default db2 uses autocommit.
You can use "update command options" to disable autocommit.

--disable autocommit
update command options using c off
.
.
.
commit
-- enable autocommit
update command options using c on
Reply With Quote
  #5 (permalink)  
Old 02-14-06, 07:47
nelapsi nelapsi is offline
Registered User
 
Join Date: Dec 2004
Posts: 43
Quote:
Originally Posted by gardenman
By default db2 uses autocommit.
You can use "update command options" to disable autocommit.

--disable autocommit
update command options using c off
.
.
.
commit
-- enable autocommit
update command options using c on
thnx..
but I'm using DB2 via ODBC..
How can I do smth like this via ODBC?
I want to use some statements with autocommit and another statements without it (with manual commit/rollback)
Reply With Quote
  #6 (permalink)  
Old 02-15-06, 08:29
nelapsi nelapsi is offline
Registered User
 
Join Date: Dec 2004
Posts: 43
Quote:
Originally Posted by nelapsi
thnx..
but I'm using DB2 via ODBC..
How can I do smth like this via ODBC?
I want to use some statements with autocommit and another statements without it (with manual commit/rollback)
thnx to all..
I did it via odbc
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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