1 /* create table t1 with two fields,
2 * insert 10 rows into the table ,
3 * select from nonexisting table.
10 AbsSqlConnection
*con
= createConnection();
11 rv
= con
->connect("root","manager");
14 AbsSqlStatement
*stmt
= createStatement();
15 stmt
->setConnection(con
);
18 strcpy(statement
,"CREATE TABLE t1(f1 INT,f2 CHAR(20));");
19 if(strcmp(getenv("DSN"),"db2")==0)
20 strcpy(statement
,"CREATE TABLE t1(f1 INT,f2 CHAR(20))");
23 rv
= stmt
->prepare(statement
);
31 rv
= stmt
->execute(rows
);
39 printf("Table created\n");
43 strcpy(statement
,"INSERT INTO t1 VALUES(?,?);");
44 if(strcmp(getenv("DSN"),"db2")==0)
45 strcpy(statement
,"INSERT INTO t1 VALUES(?,?)");
48 char f2var
[20] = "lakshya";
51 rv
= stmt
->prepare(statement
);
67 rv
= con
->beginTrans();
71 stmt
->setIntParam(1,f1var
);
72 stmt
->setStringParam(2,f2var
);
74 rv
= stmt
->execute(rows
);
80 printf("%d rows inserted\n",count
);
84 //*******************************************
86 strcpy(statement
,"SELECT * FROM t11;");
87 if(strcmp(getenv("DSN"),"db2")==0)
88 strcpy(statement
,"SELECT * FROM t11");
89 rv
= stmt
->prepare(statement
);
93 printf("test script passed\n");
94 strcpy(statement
,"DROP TABLE t1;");
95 if(strcmp(getenv("DSN"),"db2")==0)
96 strcpy(statement
,"DROP TABLE t1");
97 rv
= stmt
->prepare(statement
);
98 rv
= stmt
->execute(rows
);
99 if(rv
==OK
){printf("Table dropped\n");}
109 if(strcmp(getenv("DSN"),"oracle")==0 || strcmp(getenv("DSN"),"psql")==0 || strcmp(getenv("DSN"),"sybase")==0)
111 printf("Test script Passed\n");
112 strcpy(statement
,"DROP TABLE t1;");
113 if(strcmp(getenv("DSN"),"db2")==0)
114 strcpy(statement
,"DROP TABLE t1");
115 rv
= stmt
->prepare(statement
);
116 rv
= stmt
->execute(rows
);
117 if(rv
==OK
){printf("Table dropped\n");}
126 printf("Test script failed\n");
127 strcpy(statement
,"DROP TABLE t1;");
128 if(strcmp(getenv("DSN"),"db2")==0)
129 strcpy(statement
,"DROP TABLE t1");
130 rv
= stmt
->prepare(statement
);
131 rv
= stmt
->execute(rows
);
132 if(rv
==OK
){printf("Table dropped\n");}
142 stmt
->bindField(1,&f1var
);
143 stmt
->bindField(2,f2var
);
147 rv
= con
->beginTrans();
150 while(stmt
->fetch()!=NULL
)
164 printf("Total row fetched=%d\n",count
);