2 Creating table using all Datatypes.
3 Create table t1 with all datatypes(TINYINT,SMALLINT,INT,BIGINT,CHAR,VARCHAR,FLOAT,DOUBLE,DATE,TIME,TIMESTAMP).
12 AbsSqlConnection
*con
= createConnection();
13 rv
= con
->connect("root","manager");
18 printf("Connection opened\n");
19 AbsSqlStatement
*stmt
= createStatement();
20 stmt
->setConnection(con
);
23 strcpy(statement
,"CREATE TABLE t1(f1 TINYINT,f2 SMALLINT,f3 INT,f4 BIGINT,f5 CHAR(20),f6 VARCHAR(30),f7 FLOAT,f8 DOUBLE,f9 DATE,f10 TIME,f11 TIMESTAMP);");
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
) { delete stmt
; con
->disconnect(); delete con
; return 3; }
31 strcpy(statement
,"GETALLTABLES;");
33 rv
= stmt
->prepare(statement
);
34 if(rv
!=OK
) { delete stmt
; con
->disconnect(); delete con
; return 4; }
36 if(rv
!=OK
) { delete stmt
; con
->disconnect(); delete con
; return 5; }
37 while(stmt
->next() !=NULL
) {
38 printf("Table Name is %s\n",stmt
->getFieldValuePtr(2)); //stmt->getFieldValuePtr(2) returns the TABLE_NAME (src/sql/SqlStatement.cxx)
42 strcpy(statement
,"DROP TABLE t1;");
43 rv
= stmt
->prepare(statement
);
44 if(rv
!=OK
) { delete stmt
; con
->disconnect(); delete con
; return 6; }
45 rv
= stmt
->execute(rows
);
46 if(rv
!=OK
) { delete stmt
; con
->disconnect(); delete con
; return 7; }
47 printf("Table dropped\n");
50 printf("Connection Closed\n");
51 delete stmt
; delete con
;