adding test scripts
[csql.git] / test / sqlapi / Csql / DDLStmt / charvarcharrange.c
blob0bbae2b5c7a5f81452035bdd4bc532047028fb33
1 /*
2 Char and varchar field length should not be more than 8000 bytes.
3 CREATE TABLE t1(f1 INT,f2 CHAR(8002)); It should be failed because size should not greater than 8000
4 CREATE TABLE t1(f1 INT,f2 VARCHAR(8002)); It should be failed because size should not greater than 8000
5 */
7 #include"common.h"
9 int main()
11 DbRetVal rv = OK;
12 AbsSqlConnection *con = createConnection();
13 rv = con->connect("root","manager");
14 if(rv !=OK) {
15 delete con;
16 return 1;
18 printf("Connection opened\n");
19 AbsSqlStatement *stmt = createStatement();
20 stmt->setConnection(con);
21 //Creating Table
22 char statement[400];
23 strcpy(statement,"CREATE TABLE t1(f1 INT,f2 CHAR(8002));");
24 int rows=0;
25 rv = stmt->prepare(statement);
26 if(rv!=OK) { delete stmt; con->disconnect(); delete con; return 2; }
27 rv = stmt->execute(rows);
28 if(rv==OK) {
29 strcpy(statement,"DROP TABLE t1;");
30 rv = stmt->prepare(statement);
31 if(rv!=OK) { delete stmt; con->disconnect(); delete con; return 3; }
32 rv = stmt->execute(rows);
33 if(rv!=OK) { delete stmt; con->disconnect(); delete con; return 4; }
34 printf("Table dropped\n");
35 stmt->free();
36 delete stmt;
37 con->disconnect();
38 delete con;
39 return 5;
41 printf("Table Creation Failed\n");
42 stmt->free();
44 strcpy(statement,"CREATE TABLE t1(f1 INT,f2 VARCHAR(8002));");
45 rows=0;
46 rv = stmt->prepare(statement);
47 if(rv!=OK) { delete stmt; con->disconnect(); delete con; return 6; }
48 rv = stmt->execute(rows);
49 if(rv==OK) {
50 strcpy(statement,"DROP TABLE t1;");
51 rv = stmt->prepare(statement);
52 if(rv!=OK) { delete stmt; con->disconnect(); delete con; return 7; }
53 rv = stmt->execute(rows);
54 if(rv!=OK) { delete stmt; con->disconnect(); delete con; return 8; }
55 printf("Table dropped\n");
56 stmt->free();
57 delete stmt;
58 con->disconnect();
59 delete con;
60 return 9;
62 printf("Table Creation Failed\n");
63 stmt->free();
65 // Show all tables
66 strcpy(statement,"GETALLTABLES;");
67 rows=0;
68 rv = stmt->prepare(statement);
69 if(rv!=OK) { delete stmt; con->disconnect(); delete con; return 10; }
70 stmt->execute(rows);
71 if(rv!=OK) { delete stmt; con->disconnect(); delete con; return 11; }
72 printf("\t TABLES\n");
73 printf("\t--------\n");
74 while(stmt->next() !=NULL) {
75 printf("\t%s\n",stmt->getFieldValuePtr(2)); //stmt->getFieldValuePtr(2) returns the TABLE_NAME (src/sql/SqlStatement.cxx)
77 stmt->free();
79 con->disconnect();
80 printf("Connection Closed\n");
82 delete stmt; delete con;
83 return 0;