mysql for odbc
[csql.git] / test / adapter / Select / selecttest9.c
blobf5099560bc0b4686d622af6e254fe5687d471e7c
1 /* prepare,execute,prepare....,
2 * second prepare should pass.
4 * Author : Jitendra Lenka
5 */
7 #include<AbsSqlStatement.h>
8 #include<SqlFactory.h>
9 //#include<Info.h>
10 int main()
12 DbRetVal rv = OK;
13 AbsSqlConnection *con = SqlFactory :: createConnection(CSqlAdapter);
14 rv = con->connect("root","manager");
15 if(rv!=OK)return 1;
17 AbsSqlStatement *stmt = SqlFactory :: createStatement(CSqlAdapter);
18 stmt->setConnection(con);
19 char statement[200];
21 strcpy(statement,"CREATE TABLE T1(F1 INT,F2 CHAR(20));");
23 int rows=0;
24 rv = stmt->prepare(statement);
25 if(rv!=OK)
27 delete stmt;
28 delete con;
29 return 1;
31 printf("Prepared the statement\n");
33 rv = stmt->execute(rows);
34 if(rv!=OK)
36 delete stmt;
37 delete con;
38 return 2;
40 printf("Execute the statement\n");
43 //again prepare
45 strcpy(statement,"DROP TABLE T1;");
46 rv = stmt->prepare(statement);
47 if(rv!=OK)
49 printf("Test script failed\n");
50 return 3;
52 printf("Test script passed\n");
53 stmt->execute(rows);
54 stmt->free();
55 delete stmt;
56 delete con;
57 return 0;