]> granicus.if.org Git - postgresql/blob - src/interfaces/ecpg/test/expected/preproc-autoprep.c
180e933f59e2ee0e5a9fab72cadd0c0f1ba15048
[postgresql] / src / interfaces / ecpg / test / expected / preproc-autoprep.c
1 /* Processed by ecpg (regression mode) */
2 /* These include files are added by the preprocessor */
3 #include <ecpglib.h>
4 #include <ecpgerrno.h>
5 #include <sqlca.h>
6 /* End of automatic include section */
7 #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
8
9 #line 1 "autoprep.pgc"
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <string.h>
13
14 /* test automatic prepare for all statements */
15
16 #line 1 "regression.h"
17
18
19
20
21
22
23 #line 6 "autoprep.pgc"
24
25
26 int main(int argc, char* argv[]) {
27   /* exec sql begin declare section */
28              
29   
30 #line 10 "autoprep.pgc"
31  int item [ 4 ] , ind [ 4 ] , i = 1 ;
32 /* exec sql end declare section */
33 #line 11 "autoprep.pgc"
34
35
36   ECPGdebug(1, stderr);
37   { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); }
38 #line 14 "autoprep.pgc"
39
40
41   /* exec sql whenever sql_warning  sqlprint ; */
42 #line 16 "autoprep.pgc"
43
44   /* exec sql whenever sqlerror  sqlprint ; */
45 #line 17 "autoprep.pgc"
46
47
48   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "create table T ( Item1 int , Item2 int )", ECPGt_EOIT, ECPGt_EORT);
49 #line 19 "autoprep.pgc"
50
51 if (sqlca.sqlwarn[0] == 'W') sqlprint();
52 #line 19 "autoprep.pgc"
53
54 if (sqlca.sqlcode < 0) sqlprint();}
55 #line 19 "autoprep.pgc"
56
57
58   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , null )", ECPGt_EOIT, ECPGt_EORT);
59 #line 21 "autoprep.pgc"
60
61 if (sqlca.sqlwarn[0] == 'W') sqlprint();
62 #line 21 "autoprep.pgc"
63
64 if (sqlca.sqlcode < 0) sqlprint();}
65 #line 21 "autoprep.pgc"
66
67   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , $1  )", 
68         ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
69         ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
70 #line 22 "autoprep.pgc"
71
72 if (sqlca.sqlwarn[0] == 'W') sqlprint();
73 #line 22 "autoprep.pgc"
74
75 if (sqlca.sqlcode < 0) sqlprint();}
76 #line 22 "autoprep.pgc"
77
78   i++;
79   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , $1  )", 
80         ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
81         ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
82 #line 24 "autoprep.pgc"
83
84 if (sqlca.sqlwarn[0] == 'W') sqlprint();
85 #line 24 "autoprep.pgc"
86
87 if (sqlca.sqlcode < 0) sqlprint();}
88 #line 24 "autoprep.pgc"
89
90   { ECPGprepare(__LINE__, NULL, 0, "i", " insert into T values ( 1 , 2 ) ");
91 #line 25 "autoprep.pgc"
92
93 if (sqlca.sqlwarn[0] == 'W') sqlprint();
94 #line 25 "autoprep.pgc"
95
96 if (sqlca.sqlcode < 0) sqlprint();}
97 #line 25 "autoprep.pgc"
98
99   { ECPGdo(__LINE__, 0, 1, NULL, 0, 1, "i", ECPGt_EOIT, ECPGt_EORT);
100 #line 26 "autoprep.pgc"
101
102 if (sqlca.sqlwarn[0] == 'W') sqlprint();
103 #line 26 "autoprep.pgc"
104
105 if (sqlca.sqlcode < 0) sqlprint();}
106 #line 26 "autoprep.pgc"
107
108
109   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "select Item2 from T order by Item2 nulls last", ECPGt_EOIT, 
110         ECPGt_int,(item),(long)1,(long)4,sizeof(int), 
111         ECPGt_int,(ind),(long)1,(long)4,sizeof(int), ECPGt_EORT);
112 #line 28 "autoprep.pgc"
113
114 if (sqlca.sqlwarn[0] == 'W') sqlprint();
115 #line 28 "autoprep.pgc"
116
117 if (sqlca.sqlcode < 0) sqlprint();}
118 #line 28 "autoprep.pgc"
119
120
121   for (i=0; i<4; i++)
122         printf("item[%d] = %d\n", i, ind[i] ? -1 : item[i]);
123
124   /* declare C cursor for select Item1 from T */
125 #line 33 "autoprep.pgc"
126
127
128   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "declare C cursor for select Item1 from T", ECPGt_EOIT, ECPGt_EORT);
129 #line 35 "autoprep.pgc"
130
131 if (sqlca.sqlwarn[0] == 'W') sqlprint();
132 #line 35 "autoprep.pgc"
133
134 if (sqlca.sqlcode < 0) sqlprint();}
135 #line 35 "autoprep.pgc"
136
137
138   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "fetch 1 in C", ECPGt_EOIT, 
139         ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
140         ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
141 #line 37 "autoprep.pgc"
142
143 if (sqlca.sqlwarn[0] == 'W') sqlprint();
144 #line 37 "autoprep.pgc"
145
146 if (sqlca.sqlcode < 0) sqlprint();}
147 #line 37 "autoprep.pgc"
148
149   printf("i = %d\n", i);
150
151   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "close C", ECPGt_EOIT, ECPGt_EORT);
152 #line 40 "autoprep.pgc"
153
154 if (sqlca.sqlwarn[0] == 'W') sqlprint();
155 #line 40 "autoprep.pgc"
156
157 if (sqlca.sqlcode < 0) sqlprint();}
158 #line 40 "autoprep.pgc"
159
160
161   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "drop table T", ECPGt_EOIT, ECPGt_EORT);
162 #line 42 "autoprep.pgc"
163
164 if (sqlca.sqlwarn[0] == 'W') sqlprint();
165 #line 42 "autoprep.pgc"
166
167 if (sqlca.sqlcode < 0) sqlprint();}
168 #line 42 "autoprep.pgc"
169
170
171   { ECPGdisconnect(__LINE__, "ALL");
172 #line 44 "autoprep.pgc"
173
174 if (sqlca.sqlwarn[0] == 'W') sqlprint();
175 #line 44 "autoprep.pgc"
176
177 if (sqlca.sqlcode < 0) sqlprint();}
178 #line 44 "autoprep.pgc"
179
180
181   return 0;
182 }