Qt 4.8.4, Firebird 2.5.
I have code like this:
// model - QSqlRelationalTableModel
if( model->database().transaction() )
{
int indexDialog;
if( _index == 0 )
{
model->insertRow( model->rowCount() );
indexDialog = model->index( model->rowCount() - 1, 0 ).row();
}
else
{
indexDialog = _index;
}
DokumentDialog dialog( model, indexDialog, this );
if( dialog.
exec() == QDialog::Accepted ) {
if( dialog.submit() )// call mapper->submit();
{
if( model->database().commit() )
{
qDebug() << BOOST_CURRENT_FUNCTION;
qDebug() << "\ttransaction successful commit";
}
else
{
qDebug() << BOOST_CURRENT_FUNCTION;
qDebug() << "\ttransaction faild to commit";
qDebug() << "\t" << model->lastError().text();
model->database().rollback();
model->revert();
}
}
else
{
qDebug() << BOOST_CURRENT_FUNCTION;
qDebug() << "\tsubmit from mapper error";
qDebug() << "\t" << model->lastError().text();
model->database().rollback();
model->revert();
}
}
else
{
model->database().rollback();
model->revert();
}
}
// model - QSqlRelationalTableModel
if( model->database().transaction() )
{
int indexDialog;
if( _index == 0 )
{
model->insertRow( model->rowCount() );
indexDialog = model->index( model->rowCount() - 1, 0 ).row();
}
else
{
indexDialog = _index;
}
DokumentDialog dialog( model, indexDialog, this );
if( dialog.exec() == QDialog::Accepted )
{
if( dialog.submit() )// call mapper->submit();
{
if( model->database().commit() )
{
qDebug() << BOOST_CURRENT_FUNCTION;
qDebug() << "\ttransaction successful commit";
}
else
{
qDebug() << BOOST_CURRENT_FUNCTION;
qDebug() << "\ttransaction faild to commit";
qDebug() << "\t" << model->lastError().text();
model->database().rollback();
model->revert();
}
}
else
{
qDebug() << BOOST_CURRENT_FUNCTION;
qDebug() << "\tsubmit from mapper error";
qDebug() << "\t" << model->lastError().text();
model->database().rollback();
model->revert();
}
}
else
{
model->database().rollback();
model->revert();
}
}
To copy to clipboard, switch view to plain text mode
First insert/update is ok. Second and next returns me an error:
submit from mapper error
"invalid transaction handle (expecting explicit transaction start) Unable to execute query"
submit from mapper error
"invalid transaction handle (expecting explicit transaction start) Unable to execute query"
To copy to clipboard, switch view to plain text mode
When I comment transaction, commit, rollback then insert and updates works ok, but I want to solve transaction issue.
Bookmarks