4 char name
[196] = "PRABAKARAN";
5 int select(Table
*table
, ComparisionOp op
)
7 printf("Operator test for %d\n", op
);
9 TimeStamp
val1(1981, 12, 24, 12, 30, 30);
10 p1
.setTerm("f1", op
, &val1
);
11 table
->setCondition(&p1
);
14 while ((tuple
= (char*) table
->fetch())) {
15 printf("tuple value is ");
16 AllDataType::printVal(&id
, typeTimeStamp
,0);
17 printf(" %s \n", name
);
27 DbRetVal rv
= conn
.open("root", "manager");
30 printf("Error during connection %d\n", rv
);
33 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
34 if (dbMgr
== NULL
) { printf("Auth failed\n"); return 2;}
36 tabDef
.addField("f1", typeTimeStamp
, 0, NULL
, true);
37 tabDef
.addField("f2", typeString
, 196);
38 rv
= dbMgr
->createTable("t1", tabDef
);
39 if (rv
!= OK
) { printf("Table creation failed\n"); return 3; }
40 printf("Table created\n");
42 HashIndexInitInfo
*idxInfo
= new HashIndexInitInfo();
43 strcpy(idxInfo
->tableName
, "t1");
44 idxInfo
->list
.append("f1");
45 idxInfo
->indType
= hashIndex
;
46 idxInfo
->isUnique
= true;
47 idxInfo
->isPrimary
= true;
48 rv
= dbMgr
->createIndex("indx1", idxInfo
);
49 if (rv
== OK
) { printf("Index creation passed\n"); return 1; }
51 dbMgr
->dropTable("t1");
56 HashIndexInitInfo
*idxInfo
= new HashIndexInitInfo();
57 strcpy(idxInfo
->tableName
, "t1");
58 idxInfo
->list
.append("f1");
59 idxInfo
->indType
= treeIndex
;
60 rv
= dbMgr
->createIndex("indx1", idxInfo
);
64 Table
*table
= dbMgr
->openTable("t1");
65 if (table
== NULL
) { printf("Unable to open table\n"); return 4; }
66 table
->bindFld("f1", &id
);
67 table
->bindFld("f2", name
);
71 rv
=conn
.startTransaction();
72 if (rv
!= OK
) exit(5);
73 for(i
= 1; i
< 10; i
++) {
74 id
.setDate(1981, 12, 21+i
);
75 id
.setTime(12, 30, 27 +i
);
76 strcpy(name
, "PRABAKARAN0123456750590");
77 ret
= table
->insertTuple();
80 AllDataType::printVal(&id
, typeTimeStamp
,0);
81 printf(" %s \n", name
);
85 conn
.startTransaction();
86 select(table
, OpEquals
);
89 conn
.startTransaction();
90 select(table
, OpNotEquals
);
93 conn
.startTransaction();
94 select(table
, OpLessThan
);
97 conn
.startTransaction();
98 select( table
, OpLessThanEquals
);
101 conn
.startTransaction();
102 select( table
, OpGreaterThan
);
105 conn
.startTransaction();
106 select( table
, OpGreaterThanEquals
);
109 dbMgr
->closeTable(table
);
110 dbMgr
->dropTable("t1");