5 DbRetVal rv
= conn
.open("root", "manager");
6 if (rv
!= OK
) return 1;
7 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
8 if (dbMgr
== NULL
) { printf("Auth failed\n"); return 2;}
11 tabDef
.addField("f1", typeInt
, 0, NULL
, true);//NOT NULL
12 tabDef
.addField("f2", typeInt
, 0, NULL
, false);
13 tabDef
.addField("f3", typeString
, 20);
14 rv
= dbMgr
->createTable("t1", tabDef
);
15 if (rv
!= OK
) { printf("Table creation failed\n"); conn
.close(); return 3; }
16 printf("Table created\n");
18 Table
*table
= dbMgr
->openTable("t1");
21 printf("Unable to open table\n");
22 dbMgr
->dropTable("t1");
27 char name
[20] = "unchangedvalue";
28 table
->bindFld("f1", &id1
);
29 table
->bindFld("f2", &id2
);
30 //table->bindFld("f3", name);
32 for (int i
= 0 ; i
< 5 ; i
++)
34 conn
.startTransaction();
36 rv
= table
->insertTuple();
42 printf("Tuples inserted in 1/txn is %d\n", icount
);
43 table
->setCondition(NULL
);
44 rv
= table
->execute();
47 dbMgr
->closeTable(table
);
48 dbMgr
->dropTable("t1");
51 table
->bindFld("f2", &id2
);
55 tuple
= (char*)table
->fetch() ;
56 if (tuple
== NULL
) {break;}
57 if (table
->isFldNull(1)) printf("Column 1 is null\n");
58 if (table
->isFldNull(2)) printf("Column 2 is null\n");
59 if (table
->isFldNull(3)) printf("Column 3 is null\n");
60 printf("Binded Tuple value is %d %d %s \n", id1
, id2
, name
);
63 dbMgr
->closeTable(table
);
64 dbMgr
->dropTable("t1");