11 char name
[100];//="NIHAR";
12 int select(Table
*table
, ComparisionOp op
)
14 printf("Operator Test for %d\n",op
);
17 p1
.setTerm("f1",op
,&val1
);
18 table
->setCondition(&p1
);
21 while((tuple
=(char*) table
->fetch()))
23 printf("Tuple is %d %s \n",id
,name
);
32 DbRetVal rv
=conn
.open("root","manager");
35 printf("Error during connection %d\n", rv
);
38 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
39 if (dbMgr
== NULL
) { printf("Auth failed\n"); return 2;}
41 tabDef
.addField("f1", typeInt
, 0, NULL
, true );
42 tabDef
.addField("f2", typeString
, 100);
43 rv
= dbMgr
->createTable("t1", tabDef
);
44 if (rv
!= OK
) { printf("Table creation failed\n"); return 3; }
45 printf("Table created\n");
47 HashIndexInitInfo
*idxInfo
= new HashIndexInitInfo();
48 strcpy(idxInfo
->tableName
, "t1");
49 idxInfo
->list
.append("f1");
50 idxInfo
->indType
= hashIndex
;
51 rv
= dbMgr
->createIndex("indx1", idxInfo
);
52 if (rv
!= OK
) { printf("Index creation failed\n"); return -1; }
53 printf("Index created\n");
56 Table
*table
= dbMgr
->openTable("t1");
57 if (table
== NULL
) { printf("Unable to open table\n"); return 4; }
58 table
->bindFld("f1", &id
);
59 table
->bindFld("f2", name
);
64 rv
=conn
.startTransaction();
65 for(i
= 6; i
< 12; i
++)
67 if (rv
!= OK
) exit(5);
69 sprintf(nam
,"%s%d","NIHAR",i
);
71 ret
= table
->insertTuple();
75 conn
.startTransaction();
76 select(table
, OpEquals
);
79 conn
.startTransaction();
80 select(table
, OpNotEquals
);
83 conn
.startTransaction();
84 select(table
, OpLessThan
);
87 conn
.startTransaction();
88 select( table
, OpLessThanEquals
);
91 conn
.startTransaction();
92 select( table
, OpGreaterThan
);
95 conn
.startTransaction();
96 select( table
, OpGreaterThanEquals
);
99 dbMgr
->closeTable(table
);
100 dbMgr
->dropTable("t1");