void deleteVal(ConnectionPtr & conn, const char * b) { string insert("delete from dpak where col2="); insert += string("'") + string(b) + string("'"); try { StatementPtr stmt = conn->createStatement(); int rows = stmt->executeUpdate(insert.c_str()); cerr << "Number of rows delete: " << rows << endl; }catch(BaseException & e){ cerr << "BaseException: " << e.getMessage() << endl; } }
void deleteVal(ConnectionPtr & conn, int a) { char col1_val[10]; memset(col1_val, 0, 10); snprintf(col1_val, 10, "%li", a); string insert("delete from dpak where col1="); insert += col1_val; try { StatementPtr stmt = conn->createStatement(); int rows = stmt->executeUpdate(insert.c_str()); cerr << "Number of rows delete: " << rows << endl; }catch(BaseException & e){ cerr << "BaseException: " << e.getMessage() << endl; } }
void updateVal(ConnectionPtr & conn, int a, const char* b) { char col1_val[10]; memset(col1_val, 0, 10); snprintf(col1_val, 10, "%li", a); string insert("update dpak set col2="); insert += string("'") + string(b) + string("'"); insert += string("where col1="); insert += col1_val; try { StatementPtr stmt = conn->createStatement(); int rows = stmt->executeUpdate(insert.c_str()); cerr << "Number of rows updated: " << rows << endl; }catch(BaseException & e){ cerr << "BaseException: " << e.getMessage() << endl; } }
void rollback(ConnectionPtr & conn) { StatementPtr stmt = conn->createStatement(); stmt->executeUpdate("rollback"); cerr<<"Rollback..." << endl; }
void begin(ConnectionPtr & conn) { StatementPtr stmt = conn->createStatement(); stmt->executeUpdate("begin transaction"); cerr<<"Begin..." << endl; }
void commit(ConnectionPtr & conn) { StatementPtr stmt = conn->createStatement(); stmt->executeUpdate("commit"); cerr<<"Commit..." << endl; }