1 //Testing OR with OR operator with all comparision operator on int data type.
2 //Five tuples are inserted and then selected by setting predicates
8 DbRetVal rv
= conn
.open("root", "manager");
9 if (rv
!= OK
) return 1;
10 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
11 if (dbMgr
== NULL
) { printf("Auth failed\n"); return 2;}
13 if ( createTable(dbMgr
) != 0 ) { conn
.close(); return 3; }
14 int inscount
= insertTuple(dbMgr
, conn
);
15 //check the inscount and return error
17 Table
*table
= dbMgr
->openTable("t1");
20 printf("Unable to open table\n");
25 Condition p1
,p2
,p3
,p4
,p5
;
26 int val1
= 2, val2
= 3, val3
= 5;
27 p1
.setTerm("f1", OpEquals
, &val2
);
28 p2
.setTerm("f2", OpGreaterThan
, &val1
);
29 p3
.setTerm("f3", OpNotEquals
, &val3
);
30 p4
.setTerm("f4", OpLessThan
, &val3
);
31 p5
.setTerm("f5", OpGreaterThanEquals
, &val2
);
34 Condition cond1
, cond1a
, cond1b
, cond1c
;
35 cond1
.setTerm(p1
.getPredicate(), OpOr
, p2
.getPredicate());
36 cond1a
.setTerm(cond1
.getPredicate(), OpOr
, p3
.getPredicate());
37 cond1b
.setTerm(cond1a
.getPredicate(), OpOr
, p4
.getPredicate());
38 cond1c
.setTerm(cond1b
.getPredicate(), OpOr
, p5
.getPredicate());
39 table
->setCondition(&cond1c
);
40 printf("Predicate: (f1 ==3 OR f2 > 2 OR f3 !=5 OR f4 <5 OR f5 >=3 ) \n");
41 conn
.startTransaction();
45 Condition cond2
, cond2a
, cond2b
;
46 cond2
.setTerm(p1
.getPredicate(), OpOr
, p2
.getPredicate());
47 cond2a
.setTerm(p3
.getPredicate(), OpOr
, p4
.getPredicate());
48 cond2b
.setTerm(cond2
.getPredicate(), OpOr
, cond2a
.getPredicate());
49 table
->setCondition(&cond2b
);
50 printf("Predicate: (f1 ==3 OR f2 > 2) OR (f3 !=5 OR f4 <5) ) \n");
51 conn
.startTransaction();
55 dbMgr
->closeTable(table
);
56 dbMgr
->dropTable("t1");