4 char name
[196] = "PRABAKARAN";
5 int select(Table
*table
, ComparisionOp op
)
7 printf("Operator test for %d\n", op
);
10 p1
.setTerm("f1", op
, &val1
);
11 table
->setCondition(&p1
);
14 while ((tuple
= (char*) table
->fetch())) {
15 printf("tuple value is %hd %s \n", id
, name
);
25 DbRetVal rv
= conn
.open("root", "manager");
28 printf("Error during connection %d\n", rv
);
31 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
32 if (dbMgr
== NULL
) { printf("Auth failed\n"); return 2;}
34 tabDef
.addField("f1", typeShort
, 0, NULL
, true);
35 tabDef
.addField("f2", typeString
, 196);
36 rv
= dbMgr
->createTable("t1", tabDef
);
37 if (rv
!= OK
) { printf("Table creation failed\n"); return 3; }
38 printf("Table created\n");
41 HashIndexInitInfo
*idxInfo
= new HashIndexInitInfo();
42 strcpy(idxInfo
->tableName
, "t1");
43 idxInfo
->list
.append("f1");
44 idxInfo
->indType
= hashIndex
;
45 idxInfo
->isUnique
= true;
46 idxInfo
->isPrimary
= true;
47 rv
= dbMgr
->createIndex("indx1", idxInfo
);
48 if (rv
!= OK
) { printf("Index creation failed\n"); return -1; }
49 printf("Index created\n");
53 HashIndexInitInfo
*idxInfo
= new HashIndexInitInfo();
54 strcpy(idxInfo
->tableName
, "t1");
55 idxInfo
->list
.append("f1");
56 idxInfo
->indType
= treeIndex
;
57 rv
= dbMgr
->createIndex("indx1", idxInfo
);
58 if (rv
!= OK
) { printf("Index creation failed\n"); return -1; }
59 printf("Index created\n");
63 HashIndexInitInfo
*idxInfo
= new HashIndexInitInfo();
64 strcpy(idxInfo
->tableName
, "t1");
65 idxInfo
->list
.append("f1");
66 idxInfo
->indType
= trieIndex
;
67 rv
= dbMgr
->createIndex("indx1", idxInfo
);
68 if (rv
!= OK
) { printf("Index creation failed\n"); return -1; }
69 printf("Index created\n");
72 Table
*table
= dbMgr
->openTable("t1");
73 if (table
== NULL
) { printf("Unable to open table\n"); return 4; }
74 table
->bindFld("f1", &id
);
75 table
->bindFld("f2", name
);
79 rv
=conn
.startTransaction();
82 if (rv
!= OK
) exit(5);
84 strcpy(name
, "PRABAKARAN0123456750590");
85 ret
= table
->insertTuple();
90 conn
.startTransaction();
91 select(table
, OpEquals
);
94 conn
.startTransaction();
95 select(table
, OpNotEquals
);
98 conn
.startTransaction();
99 select(table
, OpLessThan
);
102 conn
.startTransaction();
103 select( table
, OpLessThanEquals
);
106 conn
.startTransaction();
107 select( table
, OpGreaterThan
);
110 conn
.startTransaction();
111 select( table
, OpGreaterThanEquals
);
114 dbMgr
->closeTable(table
);
115 dbMgr
->dropTable("t1");