Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DB2 BEGIN TRANSACTION 1

Status
Not open for further replies.

Retho

Programmer
Jun 28, 2004
6
0
0
DE
Hello everybody,

does DB2 support the BEGIN TRANSACTION SQL command?

When I try to use this statement to encapsulate my inserts I always get an error that shows me that DB2 does not seem to understand this statement!?

How can I lock tables/make transactions for inserts/upadates in a DBMS-independant way?

Many thanks

Kind regards
 
The concept is there, but the syntax is defferent.

Look up Compound SQL and ATOMIC, these provide a similar functionality in that several SQL statements can be grouped asa 'commitment unit'.
 
Thank you for that hint.

But is there no DBMS-independant manner which one can lock a table for concurrent inserts/updates while inserting/updating own data?

Is the BEGIN TRANSACTION statement part of the SQL-Standard (SQL92 or SQL3)?

Tank you in advance
 

If you are using CLP, then use +c option. Then, it will start a transaction. Then you should do a commit or rollback. If you terminate doing none of these, it will be rolledback.
Example is
db2 +c
This will open db2 interactive transaction session.

If you are using Java, then set AUTOCOMMIT=flase.
To lock the tables, you can use the command LOCK TABLE.. or select * from table WITH <isolation Level>.
Examples would be
LOCK TABLE ifxTec_tab in EXCLUSIVE MODE; [This is standard]
SELECT * FROM ifxTec_tab WITH RS; [specific to DB2]
Hope this clears your doubts. If you have anything more let me know.
Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top