Languages

English

Database E_OBJECT_LOCKED after QueryN

Is it bug or feature?

When I try to  ExecuteSql (DROP TABLE) after using DBEnumerator I catch E_OBJECT_LOCKED.

If I remove  rs->MoveFirst() - the code above works fine

  1.  
  2.  
  3.  
  4.  
  5. DbEnumerator* rs;
  6. rs = pDatabase->QueryN(L"SELECT count(*) FROM tbl");
  7.  
  8. if (rs)
  9. {
  10. rs->Reset();
  11. if (rs->MoveFirst() == E_SUCCESS)// If remove this line - everything OK
  12. {
  13. //
  14. }
  15. }
  16.  
  17. AppLog("DROP1");
  18. r = pDatabase->ExecuteSql(L"DROP TABLE IF EXISTS tbl", true);//Error - object locked
  19. if (IsFailed(r)) { AppLog("Error drop table r=%d %s",r,GetErrorMessage(r)); Close(); return r; }
  20. r = pDatabase->ExecuteSql(L"CREATE TABLE IF NOT EXISTS tbl (fid INTEGER PRIMARY KEY AUTOINCREMENT, fx DOUBLE, fy DOUBLE);", true);
  21. if (IsFailed(r)) { AppLog("Error CREATE TABLE r=%d",r); Close(); return r; }
  22.  
  23. AppLog("DROP2");// the same
  24. r = pDatabase->ExecuteSql(L"DROP TABLE IF EXISTS tbl", true);
  25. if (IsFailed(r)) { AppLog("Error drop table r=%d %s",r,GetErrorMessage(r)); Close(); return r; }
  26. r = pDatabase->ExecuteSql(L"CREATE TABLE IF NOT EXISTS tbl (fid INTEGER PRIMARY KEY AUTOINCREMENT, fx DOUBLE, fy DOUBLE);", true);
  27. if (IsFailed(r)) { AppLog("Error CREATE TABLE r=%d",r); Close(); return r; }
  28.  
Edited by: Vitaly on 30 Mar, 2014
View Selected Answer

Responses

1 Replies
Mark as answer
Vitaly

Find bug...

Need delete rs;