common.h
来自「b树实现源码,linux和unix下运行,速度快,极好用」· C头文件 代码 · 共 58 行
H
58 行
#include<CSql.h>int createIndex(DatabaseManager *dbMgr, bool unique){ //Creating hash index on field f1 of table t1 HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); strcpy(idxInfo->tableName, "t1"); idxInfo->list.append("f1"); idxInfo->indType = hashIndex;#ifndef DEFAULT idxInfo->isUnique = unique;#endif DbRetVal rv = dbMgr->createIndex("indx1", idxInfo); if (rv != OK) { printf("Index creation failed\n"); return 1; } printf("Index created\n"); delete idxInfo; return 0;}int createTable(DatabaseManager *dbMgr){ TableDef tabDef; tabDef.addField("f1", typeInt, 0, NULL, true); tabDef.addField("f2", typeInt); tabDef.addField("f3", typeString, 20); DbRetVal rv = dbMgr->createTable("t1", tabDef); if (rv != OK) { printf("Table creation failed\n"); return 1; } printf("Table created\n"); return 0;}int insertTupleWithSameValue(DatabaseManager *dbMgr, Connection &conn){ Table *table = dbMgr->openTable("t1"); if (table == NULL) { printf("Unable to open table\n"); return 0; } int id1 = 0, id2 = 5; char name[20] = "PRAVEEN"; table->bindFld("f1", &id1); table->bindFld("f2", &id2); table->bindFld("f3", name); int icount =0; DbRetVal rv = OK; for (int i = 0 ; i < 10 ; i++) { conn.startTransaction(); id1= 10; rv = table->insertTuple(); if (rv != OK) break; icount++; conn.commit(); } printf("Total Tuples inserted is %d\n", icount); dbMgr->closeTable(table); return icount;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?