4 char name
[196] = "PRABAKARAN";
5 int select(Table
*table
, ComparisionOp op
)
7 printf("Operator test for %d\n", op
);
11 p1
.setTerm("f1", op
, &val1
);
12 table
->setCondition(&p1
);
15 while ((tuple
= (char*) table
->fetch())) {
16 printf("tuple value is %f %s \n", id
, name
);
26 DbRetVal rv
= conn
.open("root", "manager");
29 printf("Error during connection %d\n", rv
);
32 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
33 if (dbMgr
== NULL
) { printf("Auth failed\n"); return 2;}
35 tabDef
.addField("f1", typeFloat
, 0 , NULL
, true);
36 tabDef
.addField("f2", typeString
, 196);
37 rv
= dbMgr
->createTable("t1", tabDef
);
38 if (rv
!= OK
) { printf("Table creation failed\n"); return 3; }
39 printf("Table created\n");
41 HashIndexInitInfo
*idxInfo
= new HashIndexInitInfo();
42 strcpy(idxInfo
->tableName
, "t1");
43 idxInfo
->list
.append("f1");
44 idxInfo
->isUnique
= true;
45 idxInfo
->isPrimary
= true;
46 idxInfo
->indType
= hashIndex
;
47 rv
= dbMgr
->createIndex("indx1", idxInfo
);
48 if (rv
== OK
) { printf("Index creation passed\n"); return 1; }
50 dbMgr
->dropTable("t1");
55 HashIndexInitInfo
*idxInfo
= new HashIndexInitInfo();
56 strcpy(idxInfo
->tableName
, "t1");
57 idxInfo
->list
.append("f1");
58 idxInfo
->indType
= treeIndex
;
59 rv
= dbMgr
->createIndex("indx1", idxInfo
);
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();
71 for(i
= 1.0; i
< 1.5; i
= i
+ 0.1)
73 if (rv
!= OK
) exit(5);
75 strcpy(name
, "PRABAKARAN0123456750590");
76 ret
= table
->insertTuple();
78 printf("Tuple inserted %f\n", i
);
82 conn
.startTransaction();
83 select(table
, OpEquals
);
86 conn
.startTransaction();
87 select(table
, OpNotEquals
);
90 conn
.startTransaction();
91 select(table
, OpLessThan
);
94 conn
.startTransaction();
95 select( table
, OpLessThanEquals
);
98 conn
.startTransaction();
99 select( table
, OpGreaterThan
);
102 conn
.startTransaction();
103 select( table
, OpGreaterThanEquals
);
107 dbMgr
->closeTable(table
);
108 dbMgr
->dropTable("t1");