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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A strange problem in commit

Status
Not open for further replies.

thein

Programmer
Sep 23, 2002
19
IS
I have been having problems. When i use
begin work
update tab1
onerror dosomething
update tab2
onerror dosomething
update tab3
onerror dosomething
commit work

it seems that if one table is locked when i commit for example tab3 it commits changes in table tab1 and tab2 but leaves tab3 unchanged. There are no errors when I update tables. This happens maybe ones in every week or less but is very bad when it happens. Could it be that table tab3 locks between update tab3 and commit work and doesn´t create any error.
 
Thein:

First, I'm assuming you are using Informix 4GL. Second, I think you are making an assumption that if table 3 is locked, your transaction won't commit.

I haven't checked it, but I'm not certain that a lock timing out is a fatal error so your transaction runs to completion. For sure if you call

WHENEVER ERROR CONTINUE

sometime before your code executes, the sequence of events you described happens. If table 3 is locked, the update eventually times out, the code continues with table 3 not being updated, and the transaction commits.

You should have error checking after each data management statement. If sqlca.sqlcode != 0 then do something to roll back the transaction.

Regards,


Ed
 
I am using C++ and Informix. So the code looks more like this

$begin work;
$update tab1;
if (SQLCODE != SQLOK)
dosomething;
$update tab2;
if (SQLCODE != SQLOK)
dosomething;
$update tab3;
if (SQLCODE != SQLOK)
dosomething;
$commit work;

 
thein:

OK, the idea is still the same. If table3 is locked, you are expecting your code to fail totally and the transaction be rolled back. That isn't happening. I think your update on Table3 times out, Table3 does not get updated, but your transaction still commits.

Sorry I can't help you more.

Regards,

Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top