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 %ld %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", typeLong
, 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");
40 HashIndexInitInfo
*idxInfo
= new HashIndexInitInfo();
41 strcpy(idxInfo
->tableName
, "t1");
42 idxInfo
->list
.append("f1");
43 idxInfo
->indType
= hashIndex
;
44 idxInfo
->isUnique
= true;
45 idxInfo
->isPrimary
= true;
46 rv
= dbMgr
->createIndex("indx1", idxInfo
);
47 if (rv
!= OK
) { printf("Index creation failed\n"); return -1; }
48 printf("Index created\n");
52 HashIndexInitInfo
*idxInfo
= new HashIndexInitInfo();
53 strcpy(idxInfo
->tableName
, "t1");
54 idxInfo
->list
.append("f1");
55 idxInfo
->indType
= treeIndex
;
56 rv
= dbMgr
->createIndex("indx1", idxInfo
);
57 if (rv
!= OK
) { printf("Index creation failed\n"); return -1; }
58 printf("Index created\n");
62 HashIndexInitInfo
*idxInfo
= new HashIndexInitInfo();
63 strcpy(idxInfo
->tableName
, "t1");
64 idxInfo
->list
.append("f1");
65 idxInfo
->indType
= trieIndex
;
66 rv
= dbMgr
->createIndex("indx1", idxInfo
);
67 if (rv
!= OK
) { printf("Index creation failed\n"); return -1; }
68 printf("Index created\n");
73 Table
*table
= dbMgr
->openTable("t1");
74 if (table
== NULL
) { printf("Unable to open table\n"); return 4; }
75 table
->bindFld("f1", &id
);
76 table
->bindFld("f2", name
);
80 rv
=conn
.startTransaction();
83 if (rv
!= OK
) exit(5);
85 strcpy(name
, "PRABAKARAN0123456750590");
86 ret
= table
->insertTuple();
91 conn
.startTransaction();
92 select(table
, OpEquals
);
95 conn
.startTransaction();
96 select(table
, OpNotEquals
);
99 conn
.startTransaction();
100 select(table
, OpLessThan
);
103 conn
.startTransaction();
104 select( table
, OpLessThanEquals
);
107 conn
.startTransaction();
108 select( table
, OpGreaterThan
);
111 conn
.startTransaction();
112 select( table
, OpGreaterThanEquals
);
115 dbMgr
->closeTable(table
);
116 dbMgr
->dropTable("t1");