for prevents conflicts between concurrent transactions it is better to use optimistic offline lock, but encountered with some problems:

 dbo::Transaction tr_ab_1(session);
   mod= session.find<db_mail_acc>()
      .where("id=?")
      .bind(utbl->get_field_int(n,0));

      e_uname->setText(mod->username);
      e_pass->setText(mod->password);
e_domain->setCurrentIndex(e_domain->findText( boost::lexical_cast<std::string>(mod->domain_id),Wt::MatchStartsWith));
      e_quota->setText(boost::lexical_cast<std::string>(mod->quota));
if(mod->active==0) e_active->setCurrentIndex(1); else e_active->setCurrentIndex(0);
      e_desc->setText(mod->description);
   tr_ab_1.commit();
//* I have Ext::TableView named utbl with data from db table (for mail server)
 * several users can update data by changing fields like Ext::LineEdit()
 */
try{
    dbo::Transaction tr_ab_1(session);
    std::string set;
int dom_n=boost::lexical_cast<int>(std::string(e_domain->currentText().toUTF8(),0,e_domain->currentText().toUTF8().find(" ")));
    int quota_n=boost::lexical_cast<int>(e_quota->value());
bool act_n; if(e_active->currentIndex()==0) act_n=true; else act_n=false;
    Dbo::ptr<db_mail_acc> mod2=session.find<db_mail_acc>()
.where("id=? and username= ? and password= ? and domain_id= ? and quota= ? and active= ? and description= ?") /* adding all of the fields to mod2 ptr solved conflict between transactions by checking if current row already changed
 * by another user and gives to us appropriately msg
 */
//.bind(utbl->get_field_int(n,0)).bind(mod->username).bind(mod->password).bind(mod->domain_id).bind(mod->quota).bind(mod->active)
      .bind(mod->description);
    if(mod2->username.length()!=0) {
if( mod->username != e_uname->text().toUTF8() ) mod2.modify()->username=e_uname->text().toUTF8(); if( mod->password != e_pass->text().toUTF8() ) mod2.modify()->password=e_pass->text().toUTF8();
     if( mod->domain_id != dom_n ) mod2.modify()->domain_id=dom_n;
     if( mod->quota != quota_n ) mod2.modify()->quota=quota_n;
     if( mod->active != act_n ) mod2.modify()->active=act_n;
if( mod->description != e_desc->text().toUTF8() ) mod2.modify()->description=e_desc->text().toUTF8();
     msg(0,tr("mail_msg_edit_succes")); }
     else { msg(0,tr("mail_msg_edit_fail_already_edit")); return; }
    tr_ab_1.commit();
}catch(Dbo::Exception &a) { msg( 1,a.what() ); session.rereadAll(); return; }catch(...){ msg( 1,tr("mail_msg_error") ); session.rereadAll(); return;
           }

/I obtain SIGSEGV if query that form mod2 (I mean select of data from db) return 0 rows

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
witty-interest mailing list
witty-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to