1 //Insert a tuple in a transaction and commit it
2 //scan should display the tuple
10 DbRetVal rv
= conn
.open("root", "manager");
13 printf("Error during connection %d\n", rv
);
18 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
19 if (dbMgr
== NULL
) { printf("Auth failed\n"); return 2;}
21 tabDef
.addField("f1", typeInt
);
22 tabDef
.addField("f2", typeString
, 196);
23 rv
= dbMgr
->createTable("t1", tabDef
);
24 if (rv
!= OK
) { printf("Table creation failed\n"); return 3; }
25 printf("Table created\n");
26 Table
*table
= dbMgr
->openTable("t1");
27 if (table
== NULL
) { printf("Unable to open table\n"); return 4; }
29 char name
[196] = "PRABAKARAN";
30 table
->bindFld("f1", &id
);
31 table
->bindFld("f2", name
);
35 conn
.startTransaction();
36 rv
= table
->insertTuple();
39 printf("Insertion failed \n");
44 conn
.startTransaction();
45 table
->setCondition(NULL
);
46 rv
= table
->execute();
49 dbMgr
->closeTable(table
);
50 dbMgr
->dropTable("t1");
54 void *fld2ptr
, *tuple
;
58 tuple
= (char*)table
->fetch() ;
59 if (tuple
== NULL
) {break;}
60 printf("Binded Tuple value is %d %s \n", id
, name
);
65 dbMgr
->closeTable(table
);
66 dbMgr
->dropTable("t1");
67 printf("test passed successfully");