1 //Testing Not operator with all comparision operator on int data type.
2 //Five tuples are inserted and then selected using single term predicates
3 //all with NOT operator
16 char name
[196] = "PRABAKARAN";
17 int select(Table
*table
, ComparisionOp op
)
19 printf("Operator test for %d\n", op
);
22 p1
.setTerm("f1", op
, &val1
);
24 p2
.setTerm(p1
.getPredicate(), OpNot
);
25 table
->setCondition(&p2
);
28 while ((tuple
= (char*) table
->fetch())) {
29 printf("tuple value is %d %s \n", id
, name
);
39 DbRetVal rv
= conn
.open("root", "manager");
42 printf("Error during connection %d\n", rv
);
45 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
46 if (dbMgr
== NULL
) { printf("Auth failed\n"); return 2;}
48 tabDef
.addField("f1", typeInt
, 0, NULL
, true );
49 tabDef
.addField("f2", typeString
, 196);
50 rv
= dbMgr
->createTable("t1", tabDef
);
51 if (rv
!= OK
) { printf("Table creation failed\n"); return 3; }
52 printf("Table created\n");
54 HashIndexInitInfo
*idxInfo
= new HashIndexInitInfo();
55 strcpy(idxInfo
->tableName
, "t1");
56 idxInfo
->list
.append("f1");
57 idxInfo
->indType
= hashIndex
;
58 rv
= dbMgr
->createIndex("indx1", idxInfo
);
59 if (rv
!= OK
) { printf("Index creation failed\n"); return -1; }
60 printf("Index created\n");
63 Table
*table
= dbMgr
->openTable("t1");
64 if (table
== NULL
) { printf("Unable to open table\n"); return 4; }
65 table
->bindFld("f1", &id
);
66 table
->bindFld("f2", name
);
70 rv
=conn
.startTransaction();
73 if (rv
!= OK
) exit(5);
75 strcpy(name
, "PRABAKARAN0123456750590");
76 ret
= table
->insertTuple();
81 conn
.startTransaction();
82 select(table
, OpEquals
);
85 conn
.startTransaction();
86 select(table
, OpNotEquals
);
89 conn
.startTransaction();
90 select(table
, OpLessThan
);
93 conn
.startTransaction();
94 select( table
, OpLessThanEquals
);
97 conn
.startTransaction();
98 select( table
, OpGreaterThan
);
101 conn
.startTransaction();
102 select( table
, OpGreaterThanEquals
);
105 dbMgr
->closeTable(table
);
106 dbMgr
->dropTable("t1");