adding test scripts
[csql.git] / test / sqlapi / Select / selecttest8.c
blobca579909e1dc5ca5a4cff76c1decb0513ea86323
1 /* prepare,execute,free,prepare, second prepare should pass.
3 * Author : Jitendra Lenka
4 */
6 #include"common.h"
8 int main()
10 DbRetVal rv = OK;
11 AbsSqlConnection *con = createConnection();
12 rv = con->connect("root","manager");
13 if(rv!=OK)return 1;
14 AbsSqlStatement *stmt = createStatement();
15 stmt->setConnection(con);
16 char statement[200];
17 strcpy(statement,"CREATE TABLE T1(F1 INT,F2 CHAR(20));");
18 int rows=0;
19 rv = stmt->prepare(statement);
20 if(rv!=OK) { delete stmt; delete con; return 1; }
21 printf("Prepare the Statement\n");
22 rv = stmt->execute(rows);
23 if(rv!=OK) { delete stmt; delete con; return 2; }
24 printf("Execute the Statement\n");
25 stmt->free();
26 printf("free all the resources\n");
27 //again prepare
28 strcpy(statement,"DROP TABLE T1;");
29 rv = stmt->prepare(statement);
30 if(rv!=OK) {
31 printf("Test script failed\n");
32 delete stmt; delete con; return 3;
34 printf("Again prepare passed\n");
35 //Drop the table
36 strcpy(statement,"DROP TABLE T1;");
37 rv = stmt->prepare(statement);
38 rv = stmt->execute(rows);
39 if(rv==OK)printf("Table dropped successfully\n");
40 stmt->free(); delete stmt; delete con;
41 return 0;