Line data Source code
1 : exec sql include sqlca;
2 : exec sql include ../regression;
3 : exec sql define STR 'abcdef';
4 : exec sql define INSERTNULL 1;
5 : exec sql define NUMBER 29;
6 :
7 0 : int main(void)
8 : {
9 : exec sql begin declare section;
10 0 : int i;
11 0 : char s[200];
12 : exec sql end declare section;
13 :
14 0 : ECPGdebug(1, stderr);
15 :
16 : exec sql whenever sqlerror do sqlprint();
17 0 : exec sql connect to REGRESSDB1;
18 0 :
19 0 : exec sql create table test (a int, b text);
20 0 : exec sql insert into test values (NUMBER, STR);
21 0 :
22 : exec sql ifdef INSERTNULL;
23 0 : exec sql insert into test values (NULL, 'defined');
24 0 : exec sql endif;
25 :
26 : exec sql ifndef INSERTNULL;
27 : exec sql insert into test values (NULL, 'not defined');
28 : exec sql elif SOMEOTHERVAR;
29 : exec sql insert into test values (NULL, 'someothervar defined');
30 : exec sql else;
31 0 : exec sql insert into test values (NULL, 'someothervar not defined');
32 0 : exec sql endif;
33 :
34 : exec sql define NUMBER 29;
35 :
36 0 : exec sql select INSERTNULL, NUMBER::text || '-' || STR INTO :i, :s;
37 0 :
38 0 : printf("i: %d, s: %s\n", i, s);
39 0 :
40 : exec sql undef STR;
41 : exec sql ifndef STR;
42 0 : exec sql insert into test values (NUMBER, 'no string');
43 0 : exec sql endif;
44 :
45 : exec sql define TZVAR; /* no value */
46 : exec sql define TZVAR 'UTC';
47 :
48 : exec sql ifndef TZVAR;
49 : exec sql SET TIMEZONE TO 'GMT';
50 : exec sql elif TZNAME;
51 : exec sql SET TIMEZONE TO TZNAME;
52 : exec sql else;
53 0 : exec sql SET TIMEZONE TO TZVAR;
54 0 : exec sql endif;
55 :
56 : /* test handling of a macro defined on the command line */
57 0 : exec sql select CMDLINESYM INTO :i;
58 0 : printf("original CMDLINESYM: %d\n", i);
59 :
60 : exec sql define CMDLINESYM 42;
61 :
62 0 : exec sql select CMDLINESYM INTO :i;
63 0 : printf("redefined CMDLINESYM: %d\n", i);
64 :
65 : exec sql define CMDLINESYM 43;
66 :
67 0 : exec sql select CMDLINESYM INTO :i;
68 0 : printf("redefined CMDLINESYM: %d\n", i);
69 :
70 : exec sql undef CMDLINESYM;
71 :
72 : exec sql ifdef CMDLINESYM;
73 : exec sql insert into test values (NUMBER, 'no string');
74 : exec sql endif;
75 :
76 : /* this macro should not have carried over from define_prelim.pgc */
77 : exec sql ifdef NONCMDLINESYM;
78 : exec sql insert into test values (NUMBER, 'no string');
79 : exec sql endif;
80 :
81 0 : exec sql disconnect;
82 0 : return 0;
83 0 : }
|