?????????
??????????????????????????????????????????????????????????????£???????????????????????????????У?????????????????????????????????????????????????????????Щ???????Щδ???????????????????е???????????£??????????????????????????????????2??????б???????????????DBMS???????????“??????????????”??SQL??????????????????????DBMS?????????????
??????????
???????????TRANSACTION?????????????????????SQL??????н??????????γ???????????????????????о????????????????????????????е?????????????????????????????DBMS??????????е??????д????????????????????????е??????“???????е??????????????????????λ?????е?????????????У??????????κ??????????”??DBMS???????????????????????????????ó??????????????????????????????????????£???????????κ?????????£?DBMS???????????????????????????????????????“???????????е?????????”???????
????sql????
????sql?????????????????????????????????COMMIT??ROLLBACK????????????????
????COMMIT WORK
????ROLLBACK WORK
????COMMIT??????????DMBS?????????е?????????????????????????????????????????????????ROLLBACK??????????????DBMS?????????е????????????С??????DBMS?????????????????????????????е??????????????????????????????
???????????
QSqlDatabase::database().transaction();
QSqlQuery query;
query.exec("SELECT id FROM employee WHERE name = 'Torild Halvorsen'");
if (query.next())
{
int employeeId = query.value(0).toInt();
query.exec("INSERT INTO project (id?? name?? ownerid) "
"VALUES (201?? 'Manhattan Project'?? "
+ QString::number(employeeId) + ")");
}
QSqlDatabase::database().commit();
??????????????????????????????QSqlDriver::hasFeature(QSqlDriver::Transactions)???????檔
???????????????QSqlDatabase::transaction()??????????????????????????????????????????
?????????????QSqlDatabase::commit()???????????QSqlDatabase::rollback()??????????