2 int createIndex(DatabaseManager
*dbMgr
, bool unique
)
4 //Creating hash index on field f1 of table t1
5 HashIndexInitInfo
*idxInfo
= new HashIndexInitInfo();
6 strcpy(idxInfo
->tableName
, "t1");
7 idxInfo
->list
.append("f1");
8 idxInfo
->indType
= hashIndex
;
10 idxInfo
->isUnique
= unique
;
12 DbRetVal rv
= dbMgr
->createIndex("indx1", idxInfo
);
13 if (rv
!= OK
) { printf("Index creation failed\n"); return 1; }
14 printf("Index created\n");
17 int createTable(DatabaseManager
*dbMgr
)
20 tabDef
.addField("f1", typeInt
, 0, NULL
, true, true);
21 tabDef
.addField("f2", typeInt
);
22 tabDef
.addField("f3", typeString
, 20);
23 DbRetVal rv
= dbMgr
->createTable("t1", tabDef
);
24 if (rv
!= OK
) { printf("Table creation failed\n"); return 1; }
25 printf("Table created\n");
28 int insertTupleWithSameValue(DatabaseManager
*dbMgr
, Connection
&conn
)
30 Table
*table
= dbMgr
->openTable("t1");
33 printf("Unable to open table\n");
37 char name
[20] = "PRAVEEN";
38 table
->bindFld("f1", &id1
);
39 table
->bindFld("f2", &id2
);
40 table
->bindFld("f3", name
);
43 for (int i
= 0 ; i
< 10 ; i
++)
45 conn
.startTransaction();
47 rv
= table
->insertTuple();
53 printf("Total Tuples inserted is %d\n", icount
);
54 dbMgr
->closeTable(table
);