Ejemplo n.º 1
0
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;
	}
}
Ejemplo n.º 2
0
void selectAll(ConnectionPtr & conn)
{
	StatementPtr stmt = conn->createStatement();
	ResultSetPtr res = stmt->executeQuery("select * from dpak");
	while(res->next())
	{
		int i;
		for(i=0; i< res->numColumns(); i++)
		{
			cerr << res->getString(i) << "|";
		}
		cerr << endl;
	}
}
Ejemplo n.º 3
0
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;
	}
}
Ejemplo n.º 4
0
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;
	}
}
Ejemplo n.º 5
0
void rollback(ConnectionPtr & conn)
{
	StatementPtr stmt = conn->createStatement();
	stmt->executeUpdate("rollback");
	cerr<<"Rollback..." << endl;
}
Ejemplo n.º 6
0
void begin(ConnectionPtr & conn)
{
	StatementPtr stmt = conn->createStatement();
	stmt->executeUpdate("begin transaction");
	cerr<<"Begin..." << endl;
}
Ejemplo n.º 7
0
void commit(ConnectionPtr & conn)
{
	StatementPtr stmt = conn->createStatement();
	stmt->executeUpdate("commit");
	cerr<<"Commit..." << endl;
}