@@ -355,16 +355,16 @@ void testSYSM() {
355
355
SYSM_DatabaseManager *sdm = new SYSM_DatabaseManager (rfm);
356
356
357
357
// Create the folder "testingDB" which contains the files rel.met and attr.met
358
- // t_rc rc = sdm->CreateDatabase("testingDB");
359
- // if (rc != OK) {DisplayReturnCode(rc);exit(-1);}
360
-
361
- // // Open the database to use it
362
- // rc = sdm->OpenDatabase("testingDB");
363
- // if (rc != OK) {DisplayReturnCode(rc);exit(-1);}
358
+ t_rc rc = sdm->CreateDatabase (" testingDB" );
359
+ if (rc != OK) {DisplayReturnCode (rc);exit (-1 );}
364
360
365
- t_rc rc = sdm->DropDatabase (" testingDB" );
361
+ // Open the database to use it
362
+ rc = sdm->OpenDatabase (" testingDB" );
366
363
if (rc != OK) {DisplayReturnCode (rc);exit (-1 );}
367
364
365
+ /* t_rc rc = sdm->DropDatabase("testingDB");
366
+ if (rc != OK) {DisplayReturnCode(rc);exit(-1);} */
367
+
368
368
// delete sdm;
369
369
// delete rfm;
370
370
}
@@ -410,15 +410,10 @@ void testSSQLM() {
410
410
rc = ddlm->CreateIndex (" table3" ," born" );
411
411
if (rc != OK) {DisplayReturnCode (rc);exit (-1 );}
412
412
413
-
414
-
415
413
// Drop table
416
414
// rc = ddlm->DropTable("table1");
417
415
// if (rc != OK) {DisplayReturnCode(rc);exit(-1);}
418
416
419
- // TEST IF DELETE REALLY WORKS
420
- // rc = ddlm->PrintFirstRecordInAttrMet("table2");
421
- // if (rc != OK) {DisplayReturnCode(rc);exit(-1);}
422
417
// Drop index
423
418
// rc = ddlm->DropIndex("table1","name",1);
424
419
// if (rc != OK) {DisplayReturnCode(rc);exit(-1);}
@@ -503,53 +498,26 @@ void testSSQLM() {
503
498
REM_RecordID rids[50 ];
504
499
int slott;
505
500
vector <char *> finalResultRecords3;
501
+ vector <char *> finalResultRecords7;
506
502
vector <REM_RecordID> finalResultRIDs3;
507
503
508
504
dmlm3->Where (" table1" ," id>0" ,&finalResultRecords3,&finalResultRIDs3); // ************************************
509
505
if (rc != OK) {DisplayReturnCode (rc);exit (-1 );} // ** Show all records
510
506
// **
511
- cout<<" ALL RECORDS IN THE TABLE :" <<endl; // ** (SELECT *
507
+ cout<<" ALL RECORDS IN THE TABLE1 :" <<endl; // ** (SELECT *
512
508
for (int interator = 0 ; interator < (int )finalResultRecords3.size (); interator++){// ** FROM table1
513
509
finalResultRIDs3[interator].GetSlot (slott); // ** WHERE id>0)
514
- cout<<slott<< " -> " << finalResultRecords3[interator]<<endl; // **
510
+ cout<<finalResultRecords3[interator]<<endl; // **
515
511
} // *************************************
516
512
cout<<endl;
517
513
518
- int until; // *************************************
519
- do { // ** TEST DELETE
520
- vector <char *> finalResultRecords2; // **
521
- vector <REM_RecordID> finalResultRIDs2; // **
522
- // ** (DELETE
523
- dmlm3->Where (" table1" ," age>25" ,&finalResultRecords2,&finalResultRIDs2); // ** FROM table1
524
- if (rc != OK) {DisplayReturnCode (rc);exit (-1 );} // ** WHERE age > 25)
525
- // **
526
- if (finalResultRecords2.size ()!=0 ){ // **
527
- dmlm3->Delete (" table1" ,finalResultRIDs2[0 ],finalResultRecords2[0 ]); // **
528
- if (rc != OK) {DisplayReturnCode (rc);exit (-1 );} // **
529
- } // **
530
- until = finalResultRecords2.size (); // **
531
- }while (until != 0 ); // **
532
- // **
533
- vector <char *> finalResultRecords; // **
534
- vector <REM_RecordID> finalResultRIDs; // **
535
- // **
536
- dmlm3->Where (" table1" ," id>0" ,&finalResultRecords,&finalResultRIDs); // **
537
- if (rc != OK) {DisplayReturnCode (rc);exit (-1 );} // **
538
- // **
539
- cout<<" TEST DELETE. ALL RECORDS IN THE TABLE (DELETE WHERE age > 25):" <<endl; // ** Show all records after delete
540
- for (int interator = 0 ; interator < (int )finalResultRecords.size (); interator++){// **
541
- finalResultRIDs[interator].GetSlot (slott); // **
542
- cout<<slott<<" -> " <<finalResultRecords[interator]<<endl; // **
543
- } // **************************************
544
- cout<<endl;
545
-
546
514
vector <char *> finalResultRecordsSelect; // **************************************
547
515
vector <char *> columns; // ** TEST SELECT
548
516
columns.push_back (" name" ); // ** kanw push ta columns pou 8elw na krathsw
549
517
columns.push_back (" age" ); // **
550
518
// columns.push_back("*"); //** (SELECT name, age
551
519
// ** FROM table1
552
- dmlm3->Select (" table1" ,columns,finalResultRecords ,&finalResultRecordsSelect); // ** WHERE id > 0)
520
+ dmlm3->Select (" table1" ,columns,finalResultRecords3 ,&finalResultRecordsSelect); // ** WHERE id > 0)
553
521
if (rc != OK) {DisplayReturnCode (rc);exit (-1 );} // **
554
522
// **
555
523
cout<<" TEST SELECT. RECORDS CHOPPED BY SELECT( name, age ):" <<endl; // **
@@ -561,24 +529,68 @@ void testSSQLM() {
561
529
vector <char *> finalResultRecords4; // **************************************
562
530
vector <REM_RecordID> finalResultRIDs4; // ** TEST UPDATE
563
531
// **
564
- dmlm3->Where (" table1" ," id< 2" ,&finalResultRecords4,&finalResultRIDs4); // **
532
+ dmlm3->Where (" table1" ," id> 2" ,&finalResultRecords4,&finalResultRIDs4); // **
565
533
if (rc != OK) {DisplayReturnCode (rc);exit (-1 );} // ** (UPDATE table1
566
534
// ** set age = 30
567
535
dmlm3->Update (" table1" ,finalResultRIDs4," age=30__" ); // ** WHERE id < 2)
568
536
if (rc != OK) {DisplayReturnCode (rc);exit (-1 );} // **
569
537
// **
570
- cout<<" TEST UPDATE. RECORDS AFTER UPDATE set age=30 WHERE id<2:" <<endl; // **
571
- for (int interator = 0 ; interator < (int )finalResultRecords4.size (); interator++){// **
572
- cout<<finalResultRecords4[interator]<<endl; // **
538
+ dmlm3->Where (" table1" ," id>2" ,&finalResultRecords7,&finalResultRIDs4); // **
539
+ if (rc != OK) {DisplayReturnCode (rc);exit (-1 );} // **
540
+ // **
541
+ cout<<" TEST UPDATE. RECORDS AFTER UPDATE set age=30 WHERE id>2:" <<endl; // **
542
+ for (int interator = 0 ; interator < (int )finalResultRecords7.size (); interator++){// **
543
+ cout<<finalResultRecords7[interator]<<endl; // **
573
544
} // **
574
545
cout<<endl; // **************************************
575
546
576
- cout<<" TEST JOIN. table1, table2 - age:" <<endl;
577
- rc = dmlm3->Join (" table1" ," table2" ," age" );
578
- if (rc != OK) {DisplayReturnCode (rc);exit (-1 );}
547
+ vector <char *> finalResultRecords8; // **************************************
548
+ vector <REM_RecordID> finalResultRIDs8; // **
549
+ // ** SELECT *
550
+ dmlm3->Where (" table2" ," born>0" ,&finalResultRecords8,&finalResultRIDs8); // ** FROM table2
551
+ if (rc != OK) {DisplayReturnCode (rc);exit (-1 );} // **
552
+ // **
553
+ cout<<" ALL RECORDS IN TABLE2:" <<endl; // **
554
+ for (int interator = 0 ; interator < (int )finalResultRecords8.size (); interator++){// **
555
+ cout<<finalResultRecords8[interator]<<endl; // **
556
+ } // **************************************
557
+
558
+ cout<<endl;
559
+ cout<<" TEST JOIN. table1, table2 - age:" <<endl; // **************************************
560
+ rc = dmlm3->Join (" table1" ," table2" ," age" ); // ** TEST JOIN
561
+ if (rc != OK) {DisplayReturnCode (rc);exit (-1 );} // ** SELECT *
562
+ // ** FROM table1,table2
563
+ // rc = dmlm3->Join("tempTableForJoin","table3","born"); //** WHERE table1.age = table2.age
564
+ // if (rc != OK) {DisplayReturnCode(rc);exit(-1);} //**
565
+ cout<<endl; // **************************************
579
566
580
- // rc = dmlm3->Join("tempTableForJoin","table3","born");
581
- // if (rc != OK) {DisplayReturnCode(rc);exit(-1);}
567
+ int until; // **************************************
568
+ do { // ** TEST DELETE
569
+ vector <char *> finalResultRecords2; // **
570
+ vector <REM_RecordID> finalResultRIDs2; // **
571
+ // ** (DELETE
572
+ dmlm3->Where (" table1" ," age=25" ,&finalResultRecords2,&finalResultRIDs2); // ** FROM table1
573
+ if (rc != OK) {DisplayReturnCode (rc);exit (-1 );} // ** WHERE age = 25)
574
+ // **
575
+ if (finalResultRecords2.size ()!=0 ){ // **
576
+ dmlm3->Delete (" table1" ,finalResultRIDs2[0 ],finalResultRecords2[0 ]); // **
577
+ if (rc != OK) {DisplayReturnCode (rc);exit (-1 );} // **
578
+ } // **
579
+ until = finalResultRecords2.size (); // **
580
+ }while (until != 0 ); // **
581
+ // **
582
+ vector <char *> finalResultRecords; // **
583
+ vector <REM_RecordID> finalResultRIDs; // **
584
+ // **
585
+ dmlm3->Where (" table1" ," id>0" ,&finalResultRecords,&finalResultRIDs); // **
586
+ if (rc != OK) {DisplayReturnCode (rc);exit (-1 );} // **
587
+ // **
588
+ cout<<" TEST DELETE. ALL RECORDS IN THE TABLE (DELETE WHERE age = 25):" <<endl; // ** Show all records after delete
589
+ for (int interator = 0 ; interator < (int )finalResultRecords.size (); interator++){// **
590
+ finalResultRIDs[interator].GetSlot (slott); // **
591
+ cout<<finalResultRecords[interator]<<endl; // **
592
+ } // **************************************
593
+
582
594
583
595
system (" pause" );
584
596
}
@@ -593,7 +605,7 @@ int main() {
593
605
594
606
testSYSM ();
595
607
596
- // testSSQLM();
608
+ testSSQLM ();
597
609
598
610
return (0 );
599
611
}
0 commit comments