Mapper
get_data.c
Go to the documentation of this file.
1 #include <sqlhdr.h>
2 #include <sqliapi.h>
3 static const char _Cn5[] = "democursor";
4 static const char _Cn4[] = "namecursor";
5 static const char _Cn3[] = "selectname";
6 static const char _Cn2[] = "hb5cursor";
7 static const char _Cn1[] = "selecthb5";
8 #line 1 "get_data.ec"
9 #include "prototypes_new.h"
10 /*
11  * EXEC SQL include sqlca.h;
12  */
13 #line 2 "get_data.ec"
14 
15 #line 2 "get_data.ec"
16 #line 1 "/opt/informix/incl/esql/sqlca.h"
17 /****************************************************************************
18  *
19  * Licensed Material - Property Of IBM
20  *
21  * "Restricted Materials of IBM"
22  *
23  * IBM Informix Client SDK
24  * Copyright IBM Corporation 1997, 2008. All rights reserved.
25  *
26  * Title: sqlca.h
27  * Description: SQL Control Area
28  *
29  ***************************************************************************
30  */
31 
32 #ifndef SQLCA_INCL
33 #define SQLCA_INCL
34 
35 #include "ifxtypes.h"
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 typedef struct sqlca_s
42  {
43  int4 sqlcode;
44 #ifdef DB2CLI
45  char sqlerrm[600]; /* error message parameters */
46 #else /* DB2CLI */
47  char sqlerrm[72]; /* error message parameters */
48 #endif /* DB2CLI */
49  char sqlerrp[8];
50  int4 sqlerrd[6];
51  /* 0 - estimated number of rows returned */
52  /* 1 - serial value after insert or ISAM error code */
53  /* 2 - number of rows processed */
54  /* 3 - estimated cost */
55  /* 4 - offset of the error into the SQL statement */
56  /* 5 - rowid after insert */
57 #ifdef _FGL_
58  char sqlawarn[8];
59 #else
60  struct sqlcaw_s
61  {
62  char sqlwarn0; /* = W if any of sqlwarn[1-7] = W */
63  char sqlwarn1; /* = W if any truncation occurred or
64  database has transactions or
65  no privileges revoked */
66  char sqlwarn2; /* = W if a null value returned or
67  ANSI database */
68  char sqlwarn3; /* = W if no. in select list != no. in into list or
69  turbo backend or no privileges granted */
70  char sqlwarn4; /* = W if no where clause on prepared update, delete or
71  incompatible float format */
72  char sqlwarn5; /* = W if non-ANSI statement */
73  char sqlwarn6; /* = W if server is in data replication secondary mode */
74  char sqlwarn7; /* = W if database locale is different from proc_locale
75  = W if backend XPS and if explain avoid_execute is set
76  (for select, insert, delete and update only)
77  */
78  } sqlwarn;
79 #endif
81 
82 /* NOTE: 4gl assumes that the sqlwarn structure can be defined as
83  * sqlawarn -- an 8 character string, because single-char
84  * variables are not recognized in 4gl.
85  *
86  * If this structure should change, the code generated by 4gl compiler
87  * must also change
88  */
89 
90 #define SQLNOTFOUND 100
91 
92 #ifndef IFX_THREAD
93 #ifdef DB2CLI
94 #define sqlca ifmxsqlca
95 extern struct sqlca_s sqlca;
96 #else /* DB2CLI */
97 extern struct sqlca_s sqlca;
98 #endif /* DB2CLI */
99 
100 #ifndef DRDAHELP
101 extern int4 SQLCODE;
102 #endif
103 
104 extern char SQLSTATE[];
105 #else /* IFX_THREAD */
106 extern int4 * ifx_sqlcode(void);
107 extern struct sqlca_s * ifx_sqlca(void);
108 /* ifx_sqlstate() declared in sqlhdr.h */
109 #define SQLCODE (*(ifx_sqlcode()))
110 #define SQLSTATE ((char *)(ifx_sqlstate()))
111 #define sqlca (*(ifx_sqlca()))
112 #endif /* IFX_THREAD */
113 
114 #ifdef __cplusplus
115 }
116 #endif
117 
118 #endif /* SQLCA_INCL */
119 
120 #line 103 "/opt/informix/incl/esql/sqlca.h"
121 #line 3 "get_data.ec"
122 int get_data(int dbase,int search,char *cstr,struct stn_rec *stn_record[500])
123 
124 {
125 
126 int i;
127 
128 /*
129  * EXEC SQL BEGIN DECLARE SECTION;
130  */
131 #line 9 "get_data.ec"
132 #line 10 "get_data.ec"
133  char astring[50];
134  char hb5[6];
135  char lat[10];
136  char lng[10];
137 struct stn_rec
138  {
139  char id[6];
140  char plat[9];
141  char aid[9];
142  char aid2[9];
143  char type[2];
144  char des[51];
145  char det[41];
146  char init[9];
147  char lat[7];
148  char lng[8];
149  int elev;
150  char stat[3];
151  char huc1[9];
152  char cou[4];
153  char zon[5];
154  char ownag[7];
155  char ownloc[4];
156  char maintag[7];
157  char mainloc[4];
158  int post;
159  } stn_rec;
160 /*
161  * EXEC SQL END DECLARE SECTION;
162  */
163 #line 39 "get_data.ec"
164 
165 
166 /*
167  * EXEC SQL database rawdb;
168  */
169 #line 41 "get_data.ec"
170  {
171 #line 41 "get_data.ec"
172  sqli_db_open("rawdb", 0);
173 #line 41 "get_data.ec"
174  }
175 
176 printf("dbase open %d\n",sqlca.sqlcode);
177 
178 strcpy(astring,"*");
179 strcat(astring,cstr);
180 strcat(astring,"*");
181 
182 printf("%s\n",astring);
183 
184 if(search==0) {
185 
186 /*
187  * EXEC SQL prepare selecthb5 from
188  * "select *
189  * from stn
190  * where id matches ?";
191  */
192 #line 53 "get_data.ec"
193  {
194 #line 56 "get_data.ec"
195  sqli_prep(ESQLINTVERSION, _Cn1, "select * from stn where id matches ?",(ifx_literal_t *)0, (ifx_namelist_t *)0, 2, 0, 0 );
196 #line 56 "get_data.ec"
197  }
198 
199  printf("prepare statement %d\n",sqlca.sqlcode);
200 
201 /*
202  * EXEC SQL declare hb5cursor cursor for selecthb5;
203  */
204 #line 60 "get_data.ec"
205  {
206 #line 60 "get_data.ec"
207  sqli_curs_decl_dynm(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn2, 512), _Cn2, sqli_curs_locate(ESQLINTVERSION, _Cn1, 513), 0, 0);
208 #line 60 "get_data.ec"
209  }
210 
211  printf("declare cursor %d\n",sqlca.sqlcode);
212 
213 /*
214  * EXEC SQL open hb5cursor using: astring;
215  */
216 #line 64 "get_data.ec"
217  {
218 #line 64 "get_data.ec"
219  static ifx_sqlvar_t _sqibind[] =
220  {
221  { 100, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
222 #line 64 "get_data.ec"
223  };
224  static ifx_sqlda_t _SD0 = { 1, _sqibind, {0}, 1, 0 };
225 #line 64 "get_data.ec"
226  _sqibind[0].sqldata = astring;
227  sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn2, 768), &_SD0, (char *)0, (struct value *)0, 1, 0);
228 #line 64 "get_data.ec"
229  }
230 
231  printf("open cursor %d\n",sqlca.sqlcode);
232 
233 }
234 
235 else if(search==1) {
236 
237 /*
238  * EXEC SQL prepare selectname from
239  * "select *
240  * from stn
241  * where des matches ?";
242  */
243 #line 72 "get_data.ec"
244  {
245 #line 75 "get_data.ec"
246  sqli_prep(ESQLINTVERSION, _Cn3, "select * from stn where des matches ?",(ifx_literal_t *)0, (ifx_namelist_t *)0, 2, 0, 0 );
247 #line 75 "get_data.ec"
248  }
249 
250  printf("prepare statement %d\n",sqlca.sqlcode);
251 
252 /*
253  * EXEC SQL declare namecursor cursor for selectname;
254  */
255 #line 79 "get_data.ec"
256  {
257 #line 79 "get_data.ec"
258  sqli_curs_decl_dynm(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn4, 512), _Cn4, sqli_curs_locate(ESQLINTVERSION, _Cn3, 513), 0, 0);
259 #line 79 "get_data.ec"
260  }
261 
262  printf("declare cursor %d\n",sqlca.sqlcode);
263 
264 /*
265  * EXEC SQL open namecursor using: astring;
266  */
267 #line 83 "get_data.ec"
268  {
269 #line 83 "get_data.ec"
270  static ifx_sqlvar_t _sqibind[] =
271  {
272  { 100, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
273 #line 83 "get_data.ec"
274  };
275  static ifx_sqlda_t _SD0 = { 1, _sqibind, {0}, 1, 0 };
276 #line 83 "get_data.ec"
277  _sqibind[0].sqldata = astring;
278  sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn4, 768), &_SD0, (char *)0, (struct value *)0, 1, 0);
279 #line 83 "get_data.ec"
280  }
281 
282  printf("open cursor %d\n",sqlca.sqlcode);
283 
284  }
285 
286 for(i=0;i<500;i++) {
287 
288  if(search==0)
289 /*
290  * EXEC SQL fetch hb5cursor into :stn_rec;
291  */
292 #line 92 "get_data.ec"
293  {
294 #line 92 "get_data.ec"
295  static ifx_sqlvar_t _sqobind[] =
296  {
297  { 100, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
298  { 100, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
299  { 100, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
300  { 100, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
301  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
302  { 100, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
303  { 100, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
304  { 100, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
305  { 100, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
306  { 100, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
307  { 102, sizeof((stn_rec).elev), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
308  { 100, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
309  { 100, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
310  { 100, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
311  { 100, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
312  { 100, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
313  { 100, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
314  { 100, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
315  { 100, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
316  { 102, sizeof((stn_rec).post), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
317 #line 92 "get_data.ec"
318  };
319  static ifx_sqlda_t _SD0 = { 20, _sqobind, {0}, 20, 0 };
320  static _FetchSpec _FS1 = { 0, 1, 0 };
321 #line 92 "get_data.ec"
322  _sqobind[0].sqldata = (stn_rec).id;
323 #line 92 "get_data.ec"
324  _sqobind[1].sqldata = (stn_rec).plat;
325 #line 92 "get_data.ec"
326  _sqobind[2].sqldata = (stn_rec).aid;
327 #line 92 "get_data.ec"
328  _sqobind[3].sqldata = (stn_rec).aid2;
329 #line 92 "get_data.ec"
330  _sqobind[4].sqldata = (stn_rec).type;
331 #line 92 "get_data.ec"
332  _sqobind[5].sqldata = (stn_rec).des;
333 #line 92 "get_data.ec"
334  _sqobind[6].sqldata = (stn_rec).det;
335 #line 92 "get_data.ec"
336  _sqobind[7].sqldata = (stn_rec).init;
337 #line 92 "get_data.ec"
338  _sqobind[8].sqldata = (stn_rec).lat;
339 #line 92 "get_data.ec"
340  _sqobind[9].sqldata = (stn_rec).lng;
341 #line 92 "get_data.ec"
342  _sqobind[10].sqldata = (char *) &(stn_rec).elev;
343 #line 92 "get_data.ec"
344  _sqobind[11].sqldata = (stn_rec).stat;
345 #line 92 "get_data.ec"
346  _sqobind[12].sqldata = (stn_rec).huc1;
347 #line 92 "get_data.ec"
348  _sqobind[13].sqldata = (stn_rec).cou;
349 #line 92 "get_data.ec"
350  _sqobind[14].sqldata = (stn_rec).zon;
351 #line 92 "get_data.ec"
352  _sqobind[15].sqldata = (stn_rec).ownag;
353 #line 92 "get_data.ec"
354  _sqobind[16].sqldata = (stn_rec).ownloc;
355 #line 92 "get_data.ec"
356  _sqobind[17].sqldata = (stn_rec).maintag;
357 #line 92 "get_data.ec"
358  _sqobind[18].sqldata = (stn_rec).mainloc;
359 #line 92 "get_data.ec"
360  _sqobind[19].sqldata = (char *) &(stn_rec).post;
361  sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn2, 768), (ifx_sqlda_t *)0, &_SD0, (char *)0, &_FS1);
362 #line 92 "get_data.ec"
363  }
364 /*
365  else if
366  EXEC SQL fetch namecursor into :stn_rec;
367 */
368  printf("code %d\n",sqlca.sqlcode);
369 
370  if(sqlca.sqlcode != 0)
371  break;
372 
373  memcpy(stn_record[i],&stn_rec,sizeof(struct stn_rec));
374 
375  printf("%s %s %s %s %s %s\n%s %s %s %s\n",
380 
381  }
382 
383 /*
384  * EXEC SQL close democursor;
385  */
386 #line 112 "get_data.ec"
387  {
388 #line 112 "get_data.ec"
389  sqli_curs_close(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn5, 768));
390 #line 112 "get_data.ec"
391  }
392 
393 /*return(i);
394 */
395 
396 }
397 
398 
399 
400 
401 #line 120 "get_data.ec"
static int i
struct stn_rec stn_rec
get_data(char month[4], FILE *fp, FILE *fq, int year, char id[9], int numpe, int s_day, int e_day, int divide[10], int conver[10])
Definition: get_data.c:6
char astring[50]
static const char _Cn3[]
Definition: get_data.c:5
static const char _Cn1[]
Definition: get_data.c:7
static const char _Cn4[]
Definition: get_data.c:4
static const char _Cn2[]
Definition: get_data.c:6
static const char _Cn5[]
Definition: get_data.c:3
int4 SQLCODE
struct sqlca_s ifx_sqlca_t
char SQLSTATE[]
struct sqlca_s sqlca
printf("fbuf is %s\n", fbuf)
int elev
Definition: mapp2h.h:48
double lat
Definition: mapp2h.h:41
struct database dbase
Definition: mapper.c:121
float value
char sqlwarn5
Definition: db.c:65
char sqlwarn3
Definition: db.c:61
char sqlwarn4
Definition: db.c:63
char sqlwarn7
Definition: db.c:67
char sqlwarn1
Definition: db.c:57
char sqlwarn6
Definition: db.c:66
char sqlwarn2
Definition: db.c:59
char sqlwarn0
Definition: db.c:56
Definition: db.c:43
long sqlerrd[6]
Definition: db.c:47
struct sqlca_s::sqlcaw_s sqlwarn
long sqlcode
Definition: db.c:44
char sqlerrm[72]
Definition: db.c:45
char sqlerrp[8]
Definition: db.c:46
Definition: misc.h:135
char id[6]
Definition: misc.h:137
char plat[9]
Definition: misc.h:138
char init[9]
Definition: misc.h:141
char lng[8]
Definition: misc.h:143
char stat[3]
Definition: misc.h:145
char cou[4]
Definition: misc.h:147
char aid[9]
Definition: misc.h:101
char type[2]
Definition: misc.h:103
char zon[5]
Definition: misc.h:148
char ownloc[4]
Definition: misc.h:115
char lat[7]
Definition: misc.h:142
int elev
Definition: misc.h:144
char maintag[7]
Definition: misc.h:116
int post
Definition: misc.h:151
char aid2[9]
Definition: misc.h:102
char huc1[9]
Definition: misc.h:111
char det[41]
Definition: misc.h:140
char ownag[7]
Definition: misc.h:114
char des[51]
Definition: misc.h:139