PostgreSQL Source Code  git master
sql-fetch.c File Reference
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for sql-fetch.c:

Go to the source code of this file.

Macros

#define ECPGdebug(X, Y)   ECPGdebug((X)+100,(Y))
 

Functions

int main ()
 

Macro Definition Documentation

◆ ECPGdebug

#define ECPGdebug (   X,
 
)    ECPGdebug((X)+100,(Y))

Definition at line 7 of file sql-fetch.c.

Referenced by main().

Function Documentation

◆ main()

int main ( void  )

Definition at line 25 of file sql-fetch.c.

References ECPG_NOT_FOUND, ECPGconnect(), ECPGdebug, ECPGdisconnect(), ECPGdo(), ECPGst_normal, ECPGt_char, ECPGt_const, ECPGt_EOIT, ECPGt_EORT, ECPGt_int, ECPGt_NO_INDICATOR, i, printf, sqlca, sqlprint(), and generate_unaccent_rules::str.

25  {
26  /* exec sql begin declare section */
27 
28 
29 
30 #line 9 "fetch.pgc"
31  char str [ 25 ] ;
32 
33 #line 10 "fetch.pgc"
34  int i , count = 1 , loopcount ;
35 /* exec sql end declare section */
36 #line 11 "fetch.pgc"
37 
38 
39  ECPGdebug(1, stderr);
40  { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); }
41 #line 14 "fetch.pgc"
42 
43 
44  /* exec sql whenever sql_warning sqlprint ; */
45 #line 16 "fetch.pgc"
46 
47  /* exec sql whenever sqlerror stop ; */
48 #line 17 "fetch.pgc"
49 
50 
51  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table My_Table ( Item1 int , Item2 text )", ECPGt_EOIT, ECPGt_EORT);
52 #line 19 "fetch.pgc"
53 
54 if (sqlca.sqlwarn[0] == 'W') sqlprint();
55 #line 19 "fetch.pgc"
56 
57 if (sqlca.sqlcode < 0) exit (1);}
58 #line 19 "fetch.pgc"
59 
60 
61  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into My_Table values ( 1 , 'text1' )", ECPGt_EOIT, ECPGt_EORT);
62 #line 21 "fetch.pgc"
63 
64 if (sqlca.sqlwarn[0] == 'W') sqlprint();
65 #line 21 "fetch.pgc"
66 
67 if (sqlca.sqlcode < 0) exit (1);}
68 #line 21 "fetch.pgc"
69 
70  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into My_Table values ( 2 , 'text2' )", ECPGt_EOIT, ECPGt_EORT);
71 #line 22 "fetch.pgc"
72 
73 if (sqlca.sqlwarn[0] == 'W') sqlprint();
74 #line 22 "fetch.pgc"
75 
76 if (sqlca.sqlcode < 0) exit (1);}
77 #line 22 "fetch.pgc"
78 
79  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into My_Table values ( 3 , 'text3' )", ECPGt_EOIT, ECPGt_EORT);
80 #line 23 "fetch.pgc"
81 
82 if (sqlca.sqlwarn[0] == 'W') sqlprint();
83 #line 23 "fetch.pgc"
84 
85 if (sqlca.sqlcode < 0) exit (1);}
86 #line 23 "fetch.pgc"
87 
88  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into My_Table values ( 4 , 'text4' )", ECPGt_EOIT, ECPGt_EORT);
89 #line 24 "fetch.pgc"
90 
91 if (sqlca.sqlwarn[0] == 'W') sqlprint();
92 #line 24 "fetch.pgc"
93 
94 if (sqlca.sqlcode < 0) exit (1);}
95 #line 24 "fetch.pgc"
96 
97 
98  /* declare C cursor for select * from My_Table */
99 #line 26 "fetch.pgc"
100 
101 
102  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select * from My_Table", ECPGt_EOIT, ECPGt_EORT);
103 #line 28 "fetch.pgc"
104 
105 if (sqlca.sqlwarn[0] == 'W') sqlprint();
106 #line 28 "fetch.pgc"
107 
108 if (sqlca.sqlcode < 0) exit (1);}
109 #line 28 "fetch.pgc"
110 
111 
112  /* exec sql whenever not found break ; */
113 #line 30 "fetch.pgc"
114 
115  for (loopcount = 0; loopcount < 100; loopcount++) {
116  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in C", ECPGt_EOIT,
117  ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
118  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
119  ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char),
120  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
121 #line 32 "fetch.pgc"
122 
123 if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
124 #line 32 "fetch.pgc"
125 
126 if (sqlca.sqlwarn[0] == 'W') sqlprint();
127 #line 32 "fetch.pgc"
128 
129 if (sqlca.sqlcode < 0) exit (1);}
130 #line 32 "fetch.pgc"
131 
132  printf("%d: %s\n", i, str);
133  }
134 
135  /* exec sql whenever not found continue ; */
136 #line 36 "fetch.pgc"
137 
138  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "move backward 2 in C", ECPGt_EOIT, ECPGt_EORT);
139 #line 37 "fetch.pgc"
140 
141 if (sqlca.sqlwarn[0] == 'W') sqlprint();
142 #line 37 "fetch.pgc"
143 
144 if (sqlca.sqlcode < 0) exit (1);}
145 #line 37 "fetch.pgc"
146 
147 
148  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 in C",
149  ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
150  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
151  ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
152  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
153  ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char),
154  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
155 #line 39 "fetch.pgc"
156 
157 if (sqlca.sqlwarn[0] == 'W') sqlprint();
158 #line 39 "fetch.pgc"
159 
160 if (sqlca.sqlcode < 0) exit (1);}
161 #line 39 "fetch.pgc"
162 
163  printf("%d: %s\n", i, str);
164 
165  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close C", ECPGt_EOIT, ECPGt_EORT);
166 #line 42 "fetch.pgc"
167 
168 if (sqlca.sqlwarn[0] == 'W') sqlprint();
169 #line 42 "fetch.pgc"
170 
171 if (sqlca.sqlcode < 0) exit (1);}
172 #line 42 "fetch.pgc"
173 
174 
175  /* declare D cursor for select * from My_Table where Item1 = $1 */
176 #line 44 "fetch.pgc"
177 
178 
179  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare D cursor for select * from My_Table where Item1 = $1",
180  ECPGt_const,"1",(long)1,(long)1,strlen("1"),
181  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
182 #line 46 "fetch.pgc"
183 
184 if (sqlca.sqlwarn[0] == 'W') sqlprint();
185 #line 46 "fetch.pgc"
186 
187 if (sqlca.sqlcode < 0) exit (1);}
188 #line 46 "fetch.pgc"
189 
190 
191  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in D", ECPGt_EOIT,
192  ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
193  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
194  ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char),
195  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
196 #line 48 "fetch.pgc"
197 
198 if (sqlca.sqlwarn[0] == 'W') sqlprint();
199 #line 48 "fetch.pgc"
200 
201 if (sqlca.sqlcode < 0) exit (1);}
202 #line 48 "fetch.pgc"
203 
204  printf("%d: %s\n", i, str);
205 
206  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close D", ECPGt_EOIT, ECPGt_EORT);
207 #line 51 "fetch.pgc"
208 
209 if (sqlca.sqlwarn[0] == 'W') sqlprint();
210 #line 51 "fetch.pgc"
211 
212 if (sqlca.sqlcode < 0) exit (1);}
213 #line 51 "fetch.pgc"
214 
215 
216  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table My_Table", ECPGt_EOIT, ECPGt_EORT);
217 #line 53 "fetch.pgc"
218 
219 if (sqlca.sqlwarn[0] == 'W') sqlprint();
220 #line 53 "fetch.pgc"
221 
222 if (sqlca.sqlcode < 0) exit (1);}
223 #line 53 "fetch.pgc"
224 
225 
226  { ECPGdisconnect(__LINE__, "ALL");
227 #line 55 "fetch.pgc"
228 
229 if (sqlca.sqlwarn[0] == 'W') sqlprint();
230 #line 55 "fetch.pgc"
231 
232 if (sqlca.sqlcode < 0) exit (1);}
233 #line 55 "fetch.pgc"
234 
235 
236  return 0;
237 }
#define ECPGdebug(X, Y)
Definition: sql-fetch.c:7
bool ECPGdisconnect(int lineno, const char *connection_name)
Definition: connect.c:684
#define sqlca
Definition: sqlca.h:59
bool ECPGdo(const int lineno, const int compat, const int force_indicator, const char *connection_name, const bool questionmarks, const int st, const char *query,...)
Definition: execute.c:2279
#define printf(...)
Definition: port.h:198
bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
Definition: connect.c:271
#define ECPG_NOT_FOUND
Definition: ecpgerrno.h:10
void sqlprint(void)
Definition: error.c:336
int i