Line data Source code
1 : #include <stdlib.h>
2 : #include <string.h>
3 : #include <stdio.h>
4 :
5 : exec sql include ../regression;
6 :
7 : exec sql whenever sqlerror sqlprint;
8 :
9 : exec sql define AMOUNT 6;
10 : exec sql define NAMELEN 8;
11 :
12 : exec sql type intarray is int[AMOUNT];
13 : typedef int intarray[AMOUNT];
14 :
15 : int
16 0 : main(void)
17 : {
18 : exec sql begin declare section;
19 :
20 : exec sql ifdef NAMELEN;
21 : typedef char string[NAMELEN];
22 0 : intarray amount;
23 0 : char name[AMOUNT][NAMELEN];
24 : exec sql elif AMOUNT;
25 : should not get here;
26 : exec sql else;
27 : should not get here either;
28 : exec sql endif;
29 :
30 : exec sql ifndef NAMELEN;
31 : should not get here;
32 : exec sql elif AMOUNT;
33 : exec sql ifdef NOSUCHNAME;
34 : should not get here;
35 : exec sql else;
36 0 : char letter[AMOUNT][1];
37 : #if 0
38 : int not_used;
39 : #endif
40 : exec sql endif;
41 : exec sql elif AMOUNT;
42 : should not get here;
43 : exec sql endif;
44 :
45 : exec sql end declare section;
46 0 : int i,j;
47 :
48 0 : ECPGdebug(1, stderr);
49 :
50 0 : exec sql connect to REGRESSDB1;
51 0 :
52 0 : exec sql create table test (name char(NAMELEN), amount int, letter char(1));
53 0 : exec sql commit;
54 0 :
55 0 : exec sql insert into Test (name, amount, letter) values ('false', 1, 'f');
56 0 : exec sql insert into test (name, amount, letter) values ('true', 2, 't');
57 0 : exec sql commit;
58 0 :
59 0 : exec sql select * into :name, :amount, :letter from test;
60 0 :
61 0 : for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
62 0 : {
63 : exec sql begin declare section;
64 0 : string n;
65 0 : char l = letter[i][0];
66 0 : int a = amount[i];
67 : exec sql end declare section;
68 :
69 0 : strncpy(n, name[i], NAMELEN);
70 0 : printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
71 0 : }
72 :
73 0 : exec sql drop table test;
74 0 : exec sql commit;
75 0 : exec sql disconnect;
76 0 :
77 0 : return 0;
78 0 : }
|