adding test scripts
[csql.git] / test / sqlapi / Csql / DMLStmt / selectalloperatoronalldatatype.c
blob3ec888cf7c03cf023e1b5c08c9b5169931fcb8f7
1 /*
2 Test Update conditionally using relational operators on all datatypes.
3 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);
4 Insert 5 records into t1.
5 INSERT INTO t1 VALUES(1,11,111,1111,'CSQL1','LAKSHYA1',11.00,1111.00,'2001-01-01','01:01:01','2001-01-01 01:01:01');
6 INSERT INTO t1 VALUES(2,22,222,2222,'CSQL2','LAKSHYA2',22.00,2222.00,'2002-02-02','02:02:02','2002-02-02 02:02:02');
7 INSERT INTO t1 VALUES(3,33,333,3333,'CSQL3','LAKSHYA3',33.00,3333.00,'2003-03-03','03:03:03','2003-03-03 03:03:03');
8 INSERT INTO t1 VALUES(4,44,444,4444,'CSQL4','LAKSHYA4',44.00,4444.00,'2004-04-04','04:04:04','2004-04-04 04:04:04');
9 INSERT INTO t1 VALUES(5,55,555,5555,'CSQL5','LAKSHYA5',55.00,5555.00,'2005-05-05','05:05:05','2005-05-05 05:05:05');
10 INSERT INTO t1 VALUES(6,66,666,6666,'CSQL6','LAKSHYA6',66.00,6666.00,'2006-06-06','06:06:06','2006-06-06 06:06:06');
11 INSERT INTO t1 VALUES(7,77,777,7777,'CSQL7','LAKSHYA7',77.00,7777.00,'2007-07-07','07:07:07','2007-07-07 07:07:07');
12 INSERT INTO t1 VALUES(8,88,888,8888,'CSQL8','LAKSHYA8',88.00,8888.00,'2008-08-08','08:08:08','2008-08-08 08:08:08');
13 INSERT INTO t1 VALUES(9,99,999,9999,'CSQL9','LAKSHYA9',99.00,9999.00,'2009-09-09','09:09:09','2009-09-09 09:09:09');
14 INSERT INTO t1 VALUES(10,100,1000,10000,'CSQL10',NULL,100.00,10000.00,'2010-10-10','10:10:10','2010-10-10 10:10:10');
16 SELECT * FROM t1;
17 SELECT * FROM t1 WHERE f3=111;
18 SELECT * FROM t1 WHERE f4<3333;
19 SELECT * FROM t1 WHERE f6<='LAKSHYA3';
20 SELECT * FROM t1 WHERE f9>'2008-08-08' and f10 <'10:10:10';
21 SELECT * FROM t1 WHERE f3 between 100 and 500;
22 SELECT * FROM t1 WHERE f6 like '%AKSHYA5';
23 SELECT * FROM t1 WHERE f11 in ('2005-05-05 05:05:05','2006-06-06 06:06:06');
24 SELECT * FROM t1 WHERE f3 is NOT NULL and f4=7777;
25 SELECT * FROM t1 WHERE f6 is NULL or not(f4=8888);
27 #include"common.h"
29 int main()
31 DbRetVal rv = OK;
32 AbsSqlConnection *con = createConnection();
33 rv = con->connect("root","manager");
34 if(rv !=OK) {
35 delete con;
36 return 1;
38 printf("Connection opened\n");
39 AbsSqlStatement *stmt = createStatement();
40 stmt->setConnection(con);
41 //Creating Table
42 char statement[400];
43 printf("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);\n");
44 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);");
45 int rows=0;
46 rv = stmt->prepare(statement);
47 if(rv!=OK) { delete stmt; con->disconnect(); delete con; return 2; }
48 rv = stmt->execute(rows);
49 if(rv!=OK) { delete stmt; con->disconnect(); delete con; return 3; }
50 stmt->free();
51 // Show all tables
52 strcpy(statement,"GETALLTABLES;");
53 rows=0;
54 rv = stmt->prepare(statement);
55 if(rv!=OK) { delete stmt; con->disconnect(); delete con; return 4; }
56 stmt->execute(rows);
57 if(rv!=OK) { delete stmt; con->disconnect(); delete con; return 5; }
58 while(stmt->next() !=NULL) {
59 printf("Table Name is %s\n",stmt->getFieldValuePtr(2)); //stmt->getFieldValuePtr(2) returns the TABLE_NAME (src/sql/SqlStatement.cxx)
61 stmt->free();
63 //Inserting Records
64 con->beginTrans();
65 rows=0;
66 stmt->prepare("INSERT INTO t1 VALUES(1,11,111,1111,'CSQL1','LAKSHYA1',11.00,1111.00,'2001-01-01','01:01:01','2001-01-01 01:01:01');");
67 stmt->execute(rows);
68 rows=0;
69 stmt->prepare("INSERT INTO t1 VALUES(2,22,222,2222,'CSQL2','LAKSHYA2',22.00,2222.00,'2002-02-02','02:02:02','2002-02-02 02:02:02');");
70 stmt->execute(rows);
71 rows=0;
72 stmt->prepare("INSERT INTO t1 VALUES(3,33,333,3333,'CSQL3','LAKSHYA3',33.00,3333.00,'2003-03-03','03:03:03','2003-03-03 03:03:03');");
73 stmt->execute(rows);
74 rows=0;
75 stmt->prepare("INSERT INTO t1 VALUES(4,44,444,4444,'CSQL4','LAKSHYA4',44.00,4444.00,'2004-04-04','04:04:04','2004-04-04 04:04:04');");
76 stmt->execute(rows);
77 rows=0;
78 stmt->prepare("INSERT INTO t1 VALUES(5,55,555,5555,'CSQL5','LAKSHYA5',55.00,5555.00,'2005-05-05','05:05:05','2005-05-05 05:05:05');");
79 stmt->execute(rows);
80 rows=0;
81 stmt->prepare("INSERT INTO t1 VALUES(6,66,666,6666,'CSQL6','LAKSHYA6',66.00,6666.00,'2006-06-06','06:06:06','2006-06-06 06:06:06');");
82 stmt->execute(rows);
83 rows=0;
84 stmt->prepare("INSERT INTO t1 VALUES(7,77,777,7777,'CSQL7','LAKSHYA7',77.00,7777.00,'2007-07-07','07:07:07','2007-07-07 07:07:07');");
85 stmt->execute(rows);
86 rows=0;
87 stmt->prepare("INSERT INTO t1 VALUES(8,88,888,8888,'CSQL8','LAKSHYA8',88.00,8888.00,'2008-08-08','08:08:08','2008-08-08 08:08:08');");
88 stmt->execute(rows);
89 rows=0;
90 stmt->prepare("INSERT INTO t1 VALUES(9,99,999,9999,'CSQL9','LAKSHYA9',99.00,9999.00,'2009-09-09','09:09:09','2009-09-09 09:09:09');");
91 stmt->execute(rows);
92 rows=0;
93 stmt->prepare("INSERT INTO t1 VALUES(10,100,1000,10000,'CSQL10',NULL,100.00,10000.00,'2010-10-10','10:10:10','2010-10-10 10:10:10');");
94 stmt->execute(rows);
95 con->commit();
96 stmt->free();
98 char f1var;
99 short int f2var;
100 int f3var;
101 long long f4var;
102 char f5var[20];
103 char f6var[32];
104 float f7var;
105 double f8var;
106 Date f9var;
107 Time f10var;
108 TimeStamp f11var;
110 //Fetching records after
111 printf("SELECT * FROM t1;\n");
112 strcpy(statement,"SELECT * FROM t1;");
113 rv = stmt->prepare(statement);
114 if(rv!=OK) { delete stmt; delete con; return 6; }
115 stmt->bindField(1,&f1var);
116 stmt->bindField(2,&f2var);
117 stmt->bindField(3,&f3var);
118 stmt->bindField(4,&f4var);
119 stmt->bindField(5,f5var);
120 stmt->bindField(6,f6var);
121 stmt->bindField(7,&f7var);
122 stmt->bindField(8,&f8var);
123 stmt->bindField(9,&f9var);
124 stmt->bindField(10,&f10var);
125 stmt->bindField(11,&f11var);
126 int count=0;
127 rv = con->beginTrans();
128 if(rv!=OK)return 7;
129 stmt->execute(rows);
130 while(stmt->fetch() !=NULL) {
131 if(stmt->isFldNull(1)) printf("f1=NULL | ");
132 else printf("f1=%d | ", f1var);
133 if(stmt->isFldNull(2)) printf("f2(=NULL | ");
134 else printf("f2(=%d | ", f2var);
135 if(stmt->isFldNull(3)) printf("f3=NULL | ");
136 else printf("f3=%d | ", f3var);
137 if(stmt->isFldNull(4)) printf("f4=NULL | ");
138 else printf("f4=%lld | ", f4var);
139 if(stmt->isFldNull(5)) printf("f5=NULL | ");
140 else printf("f5=%s | ", f5var);
141 if(stmt->isFldNull(6)) printf("f6=NULL | ");
142 else printf("f6=%s | ", f6var);
143 if(stmt->isFldNull(7)) printf("f7=NULL | ");
144 else printf("f7=%f | ", f7var);
145 if(stmt->isFldNull(8)) printf("f8=NULL | ");
146 else printf("f8=%lf | ", f8var);
147 if(stmt->isFldNull(9)) printf("f9=NULL | ");
148 else printf("f9=%02d-%02d-%02d | ", f9var.year(),f9var.month(),f9var.dayOfMonth());
149 if(stmt->isFldNull(10)) printf("f10=NULL | ");
150 else printf("f10=%02d:%02d:%02d | ", f10var.hours(),f10var.minutes(),f10var.seconds());
151 if(stmt->isFldNull(11)) printf("f11=NULL | ");
152 else printf("f11=%d-%d-%d %d:%d:%d | ", f11var.year(),f11var.month(),f11var.dayOfMonth(),f11var.hours(),f11var.minutes(),f11var.seconds());
153 printf("\n");
154 count++;
156 stmt->free();
157 rv = con->commit();
158 printf("%d rows selected\n",count);
160 printf("SELECT * FROM t1 WHERE f3=111;\n");
161 strcpy(statement,"SELECT * FROM t1 WHERE f3=111;");
162 rv = stmt->prepare(statement);
163 stmt->bindField(1,&f1var);
164 stmt->bindField(2,&f2var);
165 stmt->bindField(3,&f3var);
166 stmt->bindField(4,&f4var);
167 stmt->bindField(5,f5var);
168 stmt->bindField(6,f6var);
169 stmt->bindField(7,&f7var);
170 stmt->bindField(8,&f8var);
171 stmt->bindField(9,&f9var);
172 stmt->bindField(10,&f10var);
173 stmt->bindField(11,&f11var);
174 count=0;
175 rv = con->beginTrans();
176 if(rv!=OK)return 8;
177 stmt->execute(rows);
178 while(stmt->fetch() !=NULL) {
179 if(stmt->isFldNull(1)) printf("f1=NULL | ");
180 else printf("f1=%d | ", f1var);
181 if(stmt->isFldNull(2)) printf("f2=NULL | ");
182 else printf("f2=%d | ", f2var);
183 if(stmt->isFldNull(3)) printf("f3=NULL | ");
184 else printf("f3=%d | ", f3var);
185 if(stmt->isFldNull(4)) printf("f4=NULL | ");
186 else printf("f4=%lld | ", f4var);
187 if(stmt->isFldNull(5)) printf("f5=NULL | ");
188 else printf("f5=%s | ", f5var);
189 if(stmt->isFldNull(6)) printf("f6=NULL | ");
190 else printf("f6=%s | ", f6var);
191 if(stmt->isFldNull(7)) printf("f7=NULL | ");
192 else printf("f7=%f | ", f7var);
193 if(stmt->isFldNull(8)) printf("f8=NULL | ");
194 else printf("f8=%lf | ", f8var);
195 if(stmt->isFldNull(9)) printf("f9=NULL | ");
196 else printf("f9=%02d-%02d-%02d | ", f9var.year(),f9var.month(),f9var.dayOfMonth());
197 if(stmt->isFldNull(10)) printf("f10=NULL | ");
198 else printf("f10=%02d:%02d:%02d | ", f10var.hours(),f10var.minutes(),f10var.seconds());
199 if(stmt->isFldNull(11)) printf("f11=NULL | ");
200 else printf("f11=%d-%d-%d %d:%d:%d | ", f11var.year(),f11var.month(),f11var.dayOfMonth(),f11var.hours(),f11var.minutes(),f11var.seconds());
201 printf("\n");
202 count++;
204 stmt->free();
205 rv = con->commit();
206 printf("%d rows selected\n",count);
208 printf("SELECT * FROM t1 WHERE f4<3333;\n");
209 strcpy(statement,"SELECT * FROM t1 WHERE f4<3333;");
210 rv = stmt->prepare(statement);
211 stmt->bindField(1,&f1var);
212 stmt->bindField(2,&f2var);
213 stmt->bindField(3,&f3var);
214 stmt->bindField(4,&f4var);
215 stmt->bindField(5,f5var);
216 stmt->bindField(6,f6var);
217 stmt->bindField(7,&f7var);
218 stmt->bindField(8,&f8var);
219 stmt->bindField(9,&f9var);
220 stmt->bindField(10,&f10var);
221 stmt->bindField(11,&f11var);
222 count=0;
223 rv = con->beginTrans();
224 if(rv!=OK)return 9;
225 stmt->execute(rows);
226 while(stmt->fetch() !=NULL) {
227 if(stmt->isFldNull(1)) printf("f1=NULL | ");
228 else printf("f1=%d | ", f1var);
229 if(stmt->isFldNull(2)) printf("f2=NULL | ");
230 else printf("f2=%d | ", f2var);
231 if(stmt->isFldNull(3)) printf("f3=NULL | ");
232 else printf("f3=%d | ", f3var);
233 if(stmt->isFldNull(4)) printf("f4=NULL | ");
234 else printf("f4=%lld | ", f4var);
235 if(stmt->isFldNull(5)) printf("f5=NULL | ");
236 else printf("f5=%s | ", f5var);
237 if(stmt->isFldNull(6)) printf("f6=NULL | ");
238 else printf("f6=%s | ", f6var);
239 if(stmt->isFldNull(7)) printf("f7=NULL | ");
240 else printf("f7=%f | ", f7var);
241 if(stmt->isFldNull(8)) printf("f8=NULL | ");
242 else printf("f8=%lf | ", f8var);
243 if(stmt->isFldNull(9)) printf("f9=NULL | ");
244 else printf("f9=%02d-%02d-%02d | ", f9var.year(),f9var.month(),f9var.dayOfMonth());
245 if(stmt->isFldNull(10)) printf("f10=NULL | ");
246 else printf("f10=%02d:%02d:%02d | ", f10var.hours(),f10var.minutes(),f10var.seconds());
247 if(stmt->isFldNull(11)) printf("f11=NULL | ");
248 else printf("f11=%d-%d-%d %d:%d:%d | ", f11var.year(),f11var.month(),f11var.dayOfMonth(),f11var.hours(),f11var.minutes(),f11var.seconds());
249 printf("\n");
250 count++;
252 stmt->free();
253 rv = con->commit();
254 printf("%d rows selected\n",count);
256 printf("SELECT * FROM t1 WHERE f6<='LAKSHYA3';\n");
257 strcpy(statement,"SELECT * FROM t1 WHERE f6<='LAKSHYA3';");
258 rv = stmt->prepare(statement);
259 stmt->bindField(1,&f1var);
260 stmt->bindField(2,&f2var);
261 stmt->bindField(3,&f3var);
262 stmt->bindField(4,&f4var);
263 stmt->bindField(5,f5var);
264 stmt->bindField(6,f6var);
265 stmt->bindField(7,&f7var);
266 stmt->bindField(8,&f8var);
267 stmt->bindField(9,&f9var);
268 stmt->bindField(10,&f10var);
269 stmt->bindField(11,&f11var);
270 count=0;
271 rv = con->beginTrans();
272 if(rv!=OK)return 10;
273 stmt->execute(rows);
274 while(stmt->fetch() !=NULL) {
275 if(stmt->isFldNull(1)) printf("f1=NULL | ");
276 else printf("f1=%d | ", f1var);
277 if(stmt->isFldNull(2)) printf("f2=NULL | ");
278 else printf("f2=%d | ", f2var);
279 if(stmt->isFldNull(3)) printf("f3=NULL | ");
280 else printf("f3=%d | ", f3var);
281 if(stmt->isFldNull(4)) printf("f4=NULL | ");
282 else printf("f4=%lld | ", f4var);
283 if(stmt->isFldNull(5)) printf("f5=NULL | ");
284 else printf("f5=%s | ", f5var);
285 if(stmt->isFldNull(6)) printf("f6=NULL | ");
286 else printf("f6=%s | ", f6var);
287 if(stmt->isFldNull(7)) printf("f7=NULL | ");
288 else printf("f7=%f | ", f7var);
289 if(stmt->isFldNull(8)) printf("f8=NULL | ");
290 else printf("f8=%lf | ", f8var);
291 if(stmt->isFldNull(9)) printf("f9=NULL | ");
292 else printf("f9=%02d-%02d-%02d | ", f9var.year(),f9var.month(),f9var.dayOfMonth());
293 if(stmt->isFldNull(10)) printf("f10=NULL | ");
294 else printf("f10=%02d:%02d:%02d | ", f10var.hours(),f10var.minutes(),f10var.seconds());
295 if(stmt->isFldNull(11)) printf("f11=NULL | ");
296 else printf("f11=%d-%d-%d %d:%d:%d | ", f11var.year(),f11var.month(),f11var.dayOfMonth(),f11var.hours(),f11var.minutes(),f11var.seconds());
297 printf("\n");
298 count++;
300 stmt->free();
301 rv = con->commit();
302 printf("%d rows selected\n",count);
304 printf("SELECT * FROM t1 WHERE f9>'2008-08-08' and f10 <'10:10:10';\n");
305 strcpy(statement,"SELECT * FROM t1 WHERE f9>'2008-08-08' and f10 <'10:10:10';");
306 rv = stmt->prepare(statement);
307 stmt->bindField(1,&f1var);
308 stmt->bindField(2,&f2var);
309 stmt->bindField(3,&f3var);
310 stmt->bindField(4,&f4var);
311 stmt->bindField(5,f5var);
312 stmt->bindField(6,f6var);
313 stmt->bindField(7,&f7var);
314 stmt->bindField(8,&f8var);
315 stmt->bindField(9,&f9var);
316 stmt->bindField(10,&f10var);
317 stmt->bindField(11,&f11var);
318 count=0;
319 rv = con->beginTrans();
320 if(rv!=OK)return 11;
321 stmt->execute(rows);
322 while(stmt->fetch() !=NULL) {
323 if(stmt->isFldNull(1)) printf("f1=NULL | ");
324 else printf("f1=%d | ", f1var);
325 if(stmt->isFldNull(2)) printf("f2=NULL | ");
326 else printf("f2=%d | ", f2var);
327 if(stmt->isFldNull(3)) printf("f3=NULL | ");
328 else printf("f3=%d | ", f3var);
329 if(stmt->isFldNull(4)) printf("f4=NULL | ");
330 else printf("f4=%lld | ", f4var);
331 if(stmt->isFldNull(5)) printf("f5=NULL | ");
332 else printf("f5=%s | ", f5var);
333 if(stmt->isFldNull(6)) printf("f6=NULL | ");
334 else printf("f6=%s | ", f6var);
335 if(stmt->isFldNull(7)) printf("f7=NULL | ");
336 else printf("f7=%f | ", f7var);
337 if(stmt->isFldNull(8)) printf("f8=NULL | ");
338 else printf("f8=%lf | ", f8var);
339 if(stmt->isFldNull(9)) printf("f9=NULL | ");
340 else printf("f9=%02d-%02d-%02d | ", f9var.year(),f9var.month(),f9var.dayOfMonth());
341 if(stmt->isFldNull(10)) printf("f10=NULL | ");
342 else printf("f10=%02d:%02d:%02d | ", f10var.hours(),f10var.minutes(),f10var.seconds());
343 if(stmt->isFldNull(11)) printf("f11=NULL | ");
344 else printf("f11=%d-%d-%d %d:%d:%d | ", f11var.year(),f11var.month(),f11var.dayOfMonth(),f11var.hours(),f11var.minutes(),f11var.seconds());
345 printf("\n");
346 count++;
348 stmt->free();
349 rv = con->commit();
350 printf("%d rows selected\n",count);
352 printf("SELECT * FROM t1 WHERE f3 between 100 and 500;\n");
353 strcpy(statement,"SELECT * FROM t1 WHERE f3 between 100 and 500;");
354 rv = stmt->prepare(statement);
355 stmt->bindField(1,&f1var);
356 stmt->bindField(2,&f2var);
357 stmt->bindField(3,&f3var);
358 stmt->bindField(4,&f4var);
359 stmt->bindField(5,f5var);
360 stmt->bindField(6,f6var);
361 stmt->bindField(7,&f7var);
362 stmt->bindField(8,&f8var);
363 stmt->bindField(9,&f9var);
364 stmt->bindField(10,&f10var);
365 stmt->bindField(11,&f11var);
366 count=0;
367 rv = con->beginTrans();
368 if(rv!=OK)return 12;
369 stmt->execute(rows);
370 while(stmt->fetch() !=NULL) {
371 if(stmt->isFldNull(1)) printf("f1=NULL | ");
372 else printf("f1=%d | ", f1var);
373 if(stmt->isFldNull(2)) printf("f2=NULL | ");
374 else printf("f2=%d | ", f2var);
375 if(stmt->isFldNull(3)) printf("f3=NULL | ");
376 else printf("f3=%d | ", f3var);
377 if(stmt->isFldNull(4)) printf("f4=NULL | ");
378 else printf("f4=%lld | ", f4var);
379 if(stmt->isFldNull(5)) printf("f5=NULL | ");
380 else printf("f5=%s | ", f5var);
381 if(stmt->isFldNull(6)) printf("f6=NULL | ");
382 else printf("f6=%s | ", f6var);
383 if(stmt->isFldNull(7)) printf("f7=NULL | ");
384 else printf("f7=%f | ", f7var);
385 if(stmt->isFldNull(8)) printf("f8=NULL | ");
386 else printf("f8=%lf | ", f8var);
387 if(stmt->isFldNull(9)) printf("f9=NULL | ");
388 else printf("f9=%02d-%02d-%02d | ", f9var.year(),f9var.month(),f9var.dayOfMonth());
389 if(stmt->isFldNull(10)) printf("f10=NULL | ");
390 else printf("f10=%02d:%02d:%02d | ", f10var.hours(),f10var.minutes(),f10var.seconds());
391 if(stmt->isFldNull(11)) printf("f11=NULL | ");
392 else printf("f11=%d-%d-%d %d:%d:%d | ", f11var.year(),f11var.month(),f11var.dayOfMonth(),f11var.hours(),f11var.minutes(),f11var.seconds());
393 printf("\n");
394 count++;
396 stmt->free();
397 rv = con->commit();
398 printf("%d rows selected\n",count);
400 printf("SELECT * FROM t1 WHERE f6 like '%AKSHYA5';\n");
401 strcpy(statement,"SELECT * FROM t1 WHERE f6 like '%AKSHYA5';");
402 rv = stmt->prepare(statement);
403 stmt->bindField(1,&f1var);
404 stmt->bindField(2,&f2var);
405 stmt->bindField(3,&f3var);
406 stmt->bindField(4,&f4var);
407 stmt->bindField(5,f5var);
408 stmt->bindField(6,f6var);
409 stmt->bindField(7,&f7var);
410 stmt->bindField(8,&f8var);
411 stmt->bindField(9,&f9var);
412 stmt->bindField(10,&f10var);
413 stmt->bindField(11,&f11var);
414 count=0;
415 rv = con->beginTrans();
416 if(rv!=OK)return 13;
417 stmt->execute(rows);
418 while(stmt->fetch() !=NULL) {
419 if(stmt->isFldNull(1)) printf("f1=NULL | ");
420 else printf("f1=%d | ", f1var);
421 if(stmt->isFldNull(2)) printf("f2=NULL | ");
422 else printf("f2=%d | ", f2var);
423 if(stmt->isFldNull(3)) printf("f3=NULL | ");
424 else printf("f3=%d | ", f3var);
425 if(stmt->isFldNull(4)) printf("f4=NULL | ");
426 else printf("f4=%lld | ", f4var);
427 if(stmt->isFldNull(5)) printf("f5=NULL | ");
428 else printf("f5=%s | ", f5var);
429 if(stmt->isFldNull(6)) printf("f6=NULL | ");
430 else printf("f6=%s | ", f6var);
431 if(stmt->isFldNull(7)) printf("f7=NULL | ");
432 else printf("f7=%f | ", f7var);
433 if(stmt->isFldNull(8)) printf("f8=NULL | ");
434 else printf("f8=%lf | ", f8var);
435 if(stmt->isFldNull(9)) printf("f9=NULL | ");
436 else printf("f9=%02d-%02d-%02d | ", f9var.year(),f9var.month(),f9var.dayOfMonth());
437 if(stmt->isFldNull(10)) printf("f10=NULL | ");
438 else printf("f10=%02d:%02d:%02d | ", f10var.hours(),f10var.minutes(),f10var.seconds());
439 if(stmt->isFldNull(11)) printf("f11=NULL | ");
440 else printf("f11=%d-%d-%d %d:%d:%d | ", f11var.year(),f11var.month(),f11var.dayOfMonth(),f11var.hours(),f11var.minutes(),f11var.seconds());
441 printf("\n");
442 count++;
444 stmt->free();
445 rv = con->commit();
446 printf("%d rows selected\n",count);
448 printf("SELECT * FROM t1 WHERE f11 in ('2005-05-05 05:05:05','2006-06-06 06:06:06');\n");
449 strcpy(statement,"SELECT * FROM t1 WHERE f11 in ('2005-05-05 05:05:05','2006-06-06 06:06:06');");
450 rv = stmt->prepare(statement);
451 stmt->bindField(1,&f1var);
452 stmt->bindField(2,&f2var);
453 stmt->bindField(3,&f3var);
454 stmt->bindField(4,&f4var);
455 stmt->bindField(5,f5var);
456 stmt->bindField(6,f6var);
457 stmt->bindField(7,&f7var);
458 stmt->bindField(8,&f8var);
459 stmt->bindField(9,&f9var);
460 stmt->bindField(10,&f10var);
461 stmt->bindField(11,&f11var);
462 count=0;
463 rv = con->beginTrans();
464 if(rv!=OK)return 14;
465 stmt->execute(rows);
466 while(stmt->fetch() !=NULL) {
467 if(stmt->isFldNull(1)) printf("f1=NULL | ");
468 else printf("f1=%d | ", f1var);
469 if(stmt->isFldNull(2)) printf("f2=NULL | ");
470 else printf("f2=%d | ", f2var);
471 if(stmt->isFldNull(3)) printf("f3=NULL | ");
472 else printf("f3=%d | ", f3var);
473 if(stmt->isFldNull(4)) printf("f4=NULL | ");
474 else printf("f4=%lld | ", f4var);
475 if(stmt->isFldNull(5)) printf("f5=NULL | ");
476 else printf("f5=%s | ", f5var);
477 if(stmt->isFldNull(6)) printf("f6=NULL | ");
478 else printf("f6=%s | ", f6var);
479 if(stmt->isFldNull(7)) printf("f7=NULL | ");
480 else printf("f7=%f | ", f7var);
481 if(stmt->isFldNull(8)) printf("f8=NULL | ");
482 else printf("f8=%lf | ", f8var);
483 if(stmt->isFldNull(9)) printf("f9=NULL | ");
484 else printf("f9=%02d-%02d-%02d | ", f9var.year(),f9var.month(),f9var.dayOfMonth());
485 if(stmt->isFldNull(10)) printf("f10=NULL | ");
486 else printf("f10=%02d:%02d:%02d | ", f10var.hours(),f10var.minutes(),f10var.seconds());
487 if(stmt->isFldNull(11)) printf("f11=NULL | ");
488 else printf("f11=%d-%d-%d %d:%d:%d | ", f11var.year(),f11var.month(),f11var.dayOfMonth(),f11var.hours(),f11var.minutes(),f11var.seconds());
489 printf("\n");
490 count++;
492 stmt->free();
493 rv = con->commit();
494 printf("%d rows selected\n",count);
496 printf("SELECT * FROM t1 WHERE f3 is NOT NULL and f4=7777;\n");
497 strcpy(statement,"SELECT * FROM t1 WHERE f3 is NOT NULL and f4=7777;");
498 rv = stmt->prepare(statement);
499 stmt->bindField(1,&f1var);
500 stmt->bindField(2,&f2var);
501 stmt->bindField(3,&f3var);
502 stmt->bindField(4,&f4var);
503 stmt->bindField(5,f5var);
504 stmt->bindField(6,f6var);
505 stmt->bindField(7,&f7var);
506 stmt->bindField(8,&f8var);
507 stmt->bindField(9,&f9var);
508 stmt->bindField(10,&f10var);
509 stmt->bindField(11,&f11var);
510 count=0;
511 rv = con->beginTrans();
512 if(rv!=OK)return 15;
513 stmt->execute(rows);
514 while(stmt->fetch() !=NULL) {
515 if(stmt->isFldNull(1)) printf("f1=NULL | ");
516 else printf("f1=%d | ", f1var);
517 if(stmt->isFldNull(2)) printf("f2=NULL | ");
518 else printf("f2=%d | ", f2var);
519 if(stmt->isFldNull(3)) printf("f3=NULL | ");
520 else printf("f3=%d | ", f3var);
521 if(stmt->isFldNull(4)) printf("f4=NULL | ");
522 else printf("f4=%lld | ", f4var);
523 if(stmt->isFldNull(5)) printf("f5=NULL | ");
524 else printf("f5=%s | ", f5var);
525 if(stmt->isFldNull(6)) printf("f6=NULL | ");
526 else printf("f6=%s | ", f6var);
527 if(stmt->isFldNull(7)) printf("f7=NULL | ");
528 else printf("f7=%f | ", f7var);
529 if(stmt->isFldNull(8)) printf("f8=NULL | ");
530 else printf("f8=%lf | ", f8var);
531 if(stmt->isFldNull(9)) printf("f9=NULL | ");
532 else printf("f9=%02d-%02d-%02d | ", f9var.year(),f9var.month(),f9var.dayOfMonth());
533 if(stmt->isFldNull(10)) printf("f10=NULL | ");
534 else printf("f10=%02d:%02d:%02d | ", f10var.hours(),f10var.minutes(),f10var.seconds());
535 if(stmt->isFldNull(11)) printf("f11=NULL | ");
536 else printf("f11=%d-%d-%d %d:%d:%d | ", f11var.year(),f11var.month(),f11var.dayOfMonth(),f11var.hours(),f11var.minutes(),f11var.seconds());
537 printf("\n");
538 count++;
540 stmt->free();
541 rv = con->commit();
542 printf("%d rows selected\n",count);
544 printf("SELECT * FROM t1 WHERE f6 is NULL or not(f4=8888);\n");
545 strcpy(statement,"SELECT * FROM t1 WHERE f6 is NULL or not(f4=8888);");
546 rv = stmt->prepare(statement);
547 stmt->bindField(1,&f1var);
548 stmt->bindField(2,&f2var);
549 stmt->bindField(3,&f3var);
550 stmt->bindField(4,&f4var);
551 stmt->bindField(5,f5var);
552 stmt->bindField(6,f6var);
553 stmt->bindField(7,&f7var);
554 stmt->bindField(8,&f8var);
555 stmt->bindField(9,&f9var);
556 stmt->bindField(10,&f10var);
557 stmt->bindField(11,&f11var);
558 count=0;
559 rv = con->beginTrans();
560 if(rv!=OK)return 16;
561 stmt->execute(rows);
562 while(stmt->fetch() !=NULL) {
563 if(stmt->isFldNull(1)) printf("f1=NULL | ");
564 else printf("f1=%d | ", f1var);
565 if(stmt->isFldNull(2)) printf("f2=NULL | ");
566 else printf("f2=%d | ", f2var);
567 if(stmt->isFldNull(3)) printf("f3=NULL | ");
568 else printf("f3=%d | ", f3var);
569 if(stmt->isFldNull(4)) printf("f4=NULL | ");
570 else printf("f4=%lld | ", f4var);
571 if(stmt->isFldNull(5)) printf("f5=NULL | ");
572 else printf("f5=%s | ", f5var);
573 if(stmt->isFldNull(6)) printf("f6=NULL | ");
574 else printf("f6=%s | ", f6var);
575 if(stmt->isFldNull(7)) printf("f7=NULL | ");
576 else printf("f7=%f | ", f7var);
577 if(stmt->isFldNull(8)) printf("f8=NULL | ");
578 else printf("f8=%lf | ", f8var);
579 if(stmt->isFldNull(9)) printf("f9=NULL | ");
580 else printf("f9=%02d-%02d-%02d | ", f9var.year(),f9var.month(),f9var.dayOfMonth());
581 if(stmt->isFldNull(10)) printf("f10=NULL | ");
582 else printf("f10=%02d:%02d:%02d | ", f10var.hours(),f10var.minutes(),f10var.seconds());
583 if(stmt->isFldNull(11)) printf("f11=NULL | ");
584 else printf("f11=%d-%d-%d %d:%d:%d | ", f11var.year(),f11var.month(),f11var.dayOfMonth(),f11var.hours(),f11var.minutes(),f11var.seconds());
585 printf("\n");
586 count++;
588 stmt->free();
589 rv = con->commit();
590 printf("%d rows selected\n",count);
592 //Droping table
593 strcpy(statement,"DROP TABLE t1;");
594 rv = stmt->prepare(statement);
595 if(rv!=OK) { delete stmt; con->disconnect(); delete con; return 17; }
596 rv = stmt->execute(rows);
597 if(rv!=OK) { delete stmt; con->disconnect(); delete con; return 18; }
598 printf("Table dropped\n");
599 stmt->free();
600 con->disconnect();
601 printf("Connection Closed\n");
603 delete stmt; delete con;
604 return 0;