Age Owner TLA 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
6057 meskes 16 CBC 1 : main(void)
17 : {
18 : exec sql begin declare section;
19 :
20 : exec sql ifdef NAMELEN;
21 : typedef char string[NAMELEN];
22 : intarray amount;
23 : 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 : 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 : int i,j;
47 :
48 1 : ECPGdebug(1, stderr);
49 :
50 1 : exec sql connect to REGRESSDB1;
51 1 :
52 1 : exec sql create table test (name char(NAMELEN), amount int, letter char(1));
53 1 : exec sql commit;
54 1 :
55 1 : exec sql insert into Test (name, amount, letter) values ('false', 1, 'f');
56 1 : exec sql insert into test (name, amount, letter) values ('true', 2, 't');
57 1 : exec sql commit;
58 1 :
59 1 : exec sql select * into :name, :amount, :letter from test;
60 1 :
61 3 : for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
62 : {
63 : exec sql begin declare section;
64 : string n;
3444 65 2 : char l = letter[i][0];
6057 66 2 : int a = amount[i];
67 : exec sql end declare section;
68 :
69 2 : strncpy(n, name[i], NAMELEN);
70 2 : printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
71 : }
72 :
73 1 : exec sql drop table test;
74 1 : exec sql commit;
75 1 : exec sql disconnect;
76 1 :
2061 peter_e 77 1 : return 0;
78 : }
|