1 /* using markfieldnull without clearFieldNull.
2 * create table t1 with f1 and f2 field
3 * without clearFldNull() f2 field will be null always.
5 * Author : Jitendra Lenka.
13 DbRetVal rv
= conn
.open("root", "manager");
14 if (rv
!= OK
) return 1;
15 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
16 if (dbMgr
== NULL
) { printf("Auth failed\n"); return 2;}
19 tabDef
.addField("f1", typeInt
, 0, NULL
, true);
20 tabDef
.addField("f2", typeInt
);
22 rv
= dbMgr
->createTable("t1", tabDef
);
23 if (rv
!= OK
) { printf("Table creation failed\n"); conn
.close(); return 3; }
24 printf("Table created\n");
26 Table
*table
= dbMgr
->openTable("t1");
29 printf("Unable to open table\n");
30 dbMgr
->dropTable("t1");
35 char name
[20] = "PRAVEEN";
36 table
->bindFld("f1", &id1
);
37 table
->bindFld("f2", &id2
);
40 for (int i
= 0 ; i
< 10 ; i
++)
42 conn
.startTransaction();
44 if (i
%2 == 0) table
->markFldNull(2);
45 rv
= table
->insertTuple();
47 //if (i%2 == 0) table->clearFldNull(2);
52 printf("Tuples inserted in 1/txn is %d\n", icount
);
53 table
->setCondition(NULL
);
54 rv
= table
->execute();
57 dbMgr
->closeTable(table
);
58 dbMgr
->dropTable("t1");
64 tuple
= (char*)table
->fetch() ;
65 if (tuple
== NULL
) {break;}
66 if (table
->isFldNull(1)) printf("Column 1 is null\n");
67 if (table
->isFldNull(2)) printf("Column 2 is null\n");
69 printf("Binded Tuple value is %d %d \n", id1
, id2
);
73 dbMgr
->closeTable(table
);
74 dbMgr
->dropTable("t1");