catalog with -l option.
[csql.git] / tmptest / test.c
blob9a21b22c4e4be4951fd6d3fbb6c61a35317f1281
1 #include<SqlStatement.h>
2 #include<NanoTimer.h>
3 int main()
5 DbRetVal rv = OK;
6 SqlConnection *con = new SqlConnection();
7 con->connect("praba", "manager");
8 printf("Connected\n");
9 SqlStatement *stmt = new SqlStatement();
10 stmt->setConnection(con);
11 char statement[1024];
12 //strcpy(statement, "INSERT INTO t1 (f1, f2) VALUES (100, 200);");
13 strcpy(statement, "INSERT INTO t1 (f1, f2) VALUES (?, ?);");
14 //strcpy(statement, "INSERT INTO t1 VALUES (100, 200);");
15 //strcpy(statement, "INSERT INTO t1 ");
16 int rows =0;
17 rv = stmt->prepare(statement);
18 printf("Prepeared\n");
19 int id1 =100, id2 = 100;
20 if (rv != OK) {delete stmt; delete con; return -1; }
21 NanoTimer timer;
22 for (int i = 0 ; i < 10 ; i++)
24 timer.start();
25 id1 = i; id2 = i;
26 con->beginTrans();
27 stmt->setIntParam(1, id1);
28 stmt->setIntParam(2, id2);
30 stmt->execute(rows);
31 con->commit();
32 timer.stop();
34 printf("Insert %lld %lld %lld\n", timer.min(), timer.max(), timer.avg());
35 stmt->free();
36 delete stmt;
37 delete con;
38 return 0;