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 %d %s \n", id
, name
);
25 DbRetVal rv
= conn
.open("praba", "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", typeInt
, 0, NULL
, true, 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");
39 Table
*table
= dbMgr
->openTable("t1");
40 if (table
== NULL
) { printf("Unable to open table\n"); return 4; }
41 table
->bindFld("f1", &id
);
42 table
->bindFld("f2", name
);
46 rv
=conn
.startTransaction();
49 if (rv
!= OK
) exit(5);
51 strcpy(name
, "PRABAKARAN0123456750590");
52 ret
= table
->insertTuple();
57 conn
.startTransaction();
58 select(table
, OpEquals
);
61 conn
.startTransaction();
62 select(table
, OpNotEquals
);
65 conn
.startTransaction();
66 select(table
, OpLessThan
);
69 conn
.startTransaction();
70 select( table
, OpLessThanEquals
);
73 conn
.startTransaction();
74 select( table
, OpGreaterThan
);
77 conn
.startTransaction();
78 select( table
, OpGreaterThanEquals
);
83 p1
.setTerm("f1", OpEquals
, &val1
);
84 table
->setCondition(&p1
);
85 rv
= conn
.startTransaction();
88 if (rv
!= OK
) exit (1);
91 tuple
= (char*)table
->fetch() ;
92 if (tuple
== NULL
) {printf("loop break in %d\n", i
);table
->close();break;}
93 strcpy(name
, "PRABAKARAN0950576543210");
98 rv
= conn
.startTransaction();
101 if (rv
!= OK
) exit (1);
104 tuple
= (char*)table
->fetch() ;
105 if (tuple
== NULL
) {printf("loop break in %d\n", i
);table
->close();break;}
106 printf("deleting tuple %d %s \n", id
, name
);
107 table
->deleteTuple();
112 table
->setCondition(NULL
);
113 rv
= conn
.startTransaction();
115 while ((tuple
= (char*) table
->fetch())) {
116 printf("after delete tuple present. Its value is %d %s \n", id
, name
);
122 dbMgr
->closeTable(table
);
123 dbMgr
->dropTable("t1");