adding test scripts
[csql.git] / test / adapter / Select / selecttest9.c
blob52c6fe7a006b6e0c55ee186e833a7a33f6f41f85
1 /* prepare,execute,prepare....,
2 * second prepare should pass.
3 */
5 #include "common.h"
6 int main()
8 DbRetVal rv = OK;
9 AbsSqlConnection *con = createConnection();
10 rv = con->connect("root","manager");
11 if(rv!=OK)return 1;
13 AbsSqlStatement *stmt = createStatement();
14 stmt->setConnection(con);
15 char statement[200];
17 strcpy(statement,"CREATE TABLE t1(f1 INT,f2 CHAR(20));");
18 if(strcmp(getenv("DSN"),"db2")==0)
19 strcpy(statement,"CREATE TABLE t1(f1 INT,f2 CHAR(20))");
21 int rows=0;
22 rv = stmt->prepare(statement);
23 if(rv!=OK)
25 delete stmt;
26 delete con;
27 return 1;
29 printf("Prepared the statement\n");
31 rv = stmt->execute(rows);
32 if(rv!=OK)
34 delete stmt;
35 delete con;
36 return 2;
38 printf("Execute the statement\n");
39 con->commit();
41 //again prepare
43 strcpy(statement,"DROP TABLE t1;");
44 if(strcmp(getenv("DSN"),"db2")==0)
45 strcpy(statement,"DROP TABLE t1");
46 rv = stmt->prepare(statement);
47 if(rv!=OK)
49 printf("Test script failed\n");
50 return 3;
53 printf("Test script passed\n");
54 stmt->execute(rows);
55 con->commit();
56 stmt->free();
57 delete stmt;
58 delete con;
59 return 0;