home *** CD-ROM | disk | FTP | other *** search
- // Copyright 1994 A.D. Software. All Rights Reserved
-
- // OOFTEST9
-
- // this sample deletes records including related data
-
- // Simple stream I/O is used to interact with the user.
- #include "oofile.hpp"
-
-
- #include "ooftst02.inc"
-
-
- int main()
- {
- cout << "OOFILE Validation Suite - Test 9\n"
- << "Simple test to demonstrate deleting records" << endl
- << "using the database from ooftst02" << endl;
-
- if (dbConnect::fileExists("ooftst09.db"))
- theDB.openConnection("ooftst09.db");
- else {
- theDB.newConnection("ooftst09.db");
- People.AddTest2Data();
- }
-
- cout << "Entire database before deletions" << endl << theDB << endl;
-
- dbView smithVisits(People.Visits);
- smithVisits << People.Visits->VisitDate() << People.Visits->Why();
-
- People.search(People.LastName=="Smith");
- cout << "Dumping Smith and his visits: " << endl
- << People << endl
- << smithVisits << endl;
-
- cout << "Deleting Smith" << endl;
- People.start(); // workaround until dumping an entire table saves context
- // OR we get a consensus on changing the behaviour of iterators that reach the end
- // of the selection
- People.deleteRecord();
-
- cout << "Entire database without Smith" << endl << theDB << endl;
-
-
- cout << "Deleting all remaining records" << endl;
- People.deleteAll();
-
- cout << "Entire database - should be empty" << endl << theDB << endl;
-
- cout << "done" << endl;
-
- return EXIT_SUCCESS;
- }