1 //Insert a tuple in a transaction and abort it
2 //scan should not display the inserted tuple.
8 DbRetVal rv
= conn
.open("root", "manager");
9 if (rv
!= OK
) { printf("Unable to open database\n"); return 1;}
10 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
11 if (dbMgr
== NULL
) { printf("Auth failed\n"); return 2;}
13 tabDef
.addField("f1", typeInt
);
14 tabDef
.addField("f2", typeString
, 196);
15 rv
= dbMgr
->createTable("t1", tabDef
);
16 if (rv
!= OK
) { printf("Table creation failed\n"); return 3; }
17 printf("Table created\n");
18 Table
*table
= dbMgr
->openTable("t1");
19 if (table
== NULL
) { printf("Unable to open table\n"); return 4; }
21 char name
[196] = "ARVIND KOTHI";
22 table
->bindFld("f1", &id
);
23 table
->bindFld("f2", name
);
28 conn
.startTransaction();
29 rv
= table
->insertTuple();
32 printf("Insertion failed at %d th tuple", i
+1);
33 dbMgr
->closeTable(table
);
34 dbMgr
->dropTable("t1");
39 printf("%d tuples are inserted into the dababase\n", i
);
42 conn
.startTransaction();
43 rv
= table
->insertTuple();
46 printf("Insertion failed at %d th tuple", i
+1);
47 dbMgr
->closeTable(table
);
48 dbMgr
->dropTable("t1");
53 table
->setCondition(NULL
);
57 tuple
= (char*)table
->fetch() ;
58 if (tuple
== NULL
) {break;}
59 printf("\nBinded Tuple value is %d %s", id
, name
);
63 dbMgr
->closeTable(table
);
64 dbMgr
->dropTable("t1");