Home » U++ Library support » U++ SQL » OkCommit problem
OkCommit problem [message #5134] |
Wed, 06 September 2006 18:53 |
zsolt
Messages: 698 Registered: December 2005 Location: Budapest, Hungary
|
Contributor |
|
|
The problem is this method:
bool OkCommit(SqlSession& session, const char *msg) {
if(ErrorRollback(session, msg))
return false;
session.Commit();
return true;
}
In the case of unsuccessful commit, nothing happens. This way it is very hard to detect the problem, because the next execution generates an error.
So I changed the method to this:
bool OkCommit(SqlSession& session, const char *msg) {
if(ErrorRollback(session, msg))
return false;
do{
session.Commit();
if(!session.WasError())
{
session.ClearError();
return true;
}
}while(IDRETRY==SqlError(t_("Unable to commit changes to database."), session, true));
return false;
}
|
|
|
|
Re: OkCommit problem [message #5136 is a reply to message #5135] |
Wed, 06 September 2006 20:37 |
zsolt
Messages: 698 Registered: December 2005 Location: Budapest, Hungary
|
Contributor |
|
|
luzr wrote on Wed, 06 September 2006 19:51 | Seems like a good idea. However, "Retry" is a bit strange IMO - if you are not able to commit, there is something pretty wrong with your database connection...
Maybe, in that case, application abort would be in place.
Mirek
|
Yes, you are right. I changed it to this:
bool OkCommit(SqlSession& session, const char *msg) {
if(ErrorRollback(session, msg))
return false;
session.Commit();
if(session.WasError())
return false;
session.ClearError();
return true;
}
Application abort would be too drastic, I think, because this is one of the connections only. Programmer can use return value of OkCommit().
|
|
|
|
|
|
|
Goto Forum:
Current Time: Sat Jun 08 07:46:28 CEST 2024
Total time taken to generate the page: 0.02469 seconds
|