Mapper
climo_search.c
Go to the documentation of this file.
1 #include <sqlhdr.h>
2 #include <sqliapi.h>
3 #line 1 "climo_search.ec"
4 #include "prototypes_new.h"
5 /*
6  * EXEC SQL include sqlca.h;
7  */
8 #line 2 "climo_search.ec"
9 
10 #line 2 "climo_search.ec"
11 #line 1 "/opt/informix/incl/esql/sqlca.h"
12 /****************************************************************************
13  *
14  * Licensed Material - Property Of IBM
15  *
16  * "Restricted Materials of IBM"
17  *
18  * IBM Informix Client SDK
19  * Copyright IBM Corporation 1997, 2008. All rights reserved.
20  *
21  * Title: sqlca.h
22  * Description: SQL Control Area
23  *
24  ***************************************************************************
25  */
26 
27 #ifndef SQLCA_INCL
28 #define SQLCA_INCL
29 
30 #include "ifxtypes.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 typedef struct sqlca_s
37  {
38  int4 sqlcode;
39 #ifdef DB2CLI
40  char sqlerrm[600]; /* error message parameters */
41 #else /* DB2CLI */
42  char sqlerrm[72]; /* error message parameters */
43 #endif /* DB2CLI */
44  char sqlerrp[8];
45  int4 sqlerrd[6];
46  /* 0 - estimated number of rows returned */
47  /* 1 - serial value after insert or ISAM error code */
48  /* 2 - number of rows processed */
49  /* 3 - estimated cost */
50  /* 4 - offset of the error into the SQL statement */
51  /* 5 - rowid after insert */
52 #ifdef _FGL_
53  char sqlawarn[8];
54 #else
55  struct sqlcaw_s
56  {
57  char sqlwarn0; /* = W if any of sqlwarn[1-7] = W */
58  char sqlwarn1; /* = W if any truncation occurred or
59  database has transactions or
60  no privileges revoked */
61  char sqlwarn2; /* = W if a null value returned or
62  ANSI database */
63  char sqlwarn3; /* = W if no. in select list != no. in into list or
64  turbo backend or no privileges granted */
65  char sqlwarn4; /* = W if no where clause on prepared update, delete or
66  incompatible float format */
67  char sqlwarn5; /* = W if non-ANSI statement */
68  char sqlwarn6; /* = W if server is in data replication secondary mode */
69  char sqlwarn7; /* = W if database locale is different from proc_locale
70  = W if backend XPS and if explain avoid_execute is set
71  (for select, insert, delete and update only)
72  */
73  } sqlwarn;
74 #endif
76 
77 /* NOTE: 4gl assumes that the sqlwarn structure can be defined as
78  * sqlawarn -- an 8 character string, because single-char
79  * variables are not recognized in 4gl.
80  *
81  * If this structure should change, the code generated by 4gl compiler
82  * must also change
83  */
84 
85 #define SQLNOTFOUND 100
86 
87 #ifndef IFX_THREAD
88 #ifdef DB2CLI
89 #define sqlca ifmxsqlca
90 extern struct sqlca_s sqlca;
91 #else /* DB2CLI */
92 extern struct sqlca_s sqlca;
93 #endif /* DB2CLI */
94 
95 #ifndef DRDAHELP
96 extern int4 SQLCODE;
97 #endif
98 
99 extern char SQLSTATE[];
100 #else /* IFX_THREAD */
101 extern int4 * ifx_sqlcode(void);
102 extern struct sqlca_s * ifx_sqlca(void);
103 /* ifx_sqlstate() declared in sqlhdr.h */
104 #define SQLCODE (*(ifx_sqlcode()))
105 #define SQLSTATE ((char *)(ifx_sqlstate()))
106 #define sqlca (*(ifx_sqlca()))
107 #endif /* IFX_THREAD */
108 
109 #ifdef __cplusplus
110 }
111 #endif
112 
113 #endif /* SQLCA_INCL */
114 
115 #line 103 "/opt/informix/incl/esql/sqlca.h"
116 #line 3 "climo_search.ec"
117 
118 int climo_search(char *hb5,char *parm,struct stim begin_date,struct stim
119 end_date,struct stn_values *stn_values)
120 
121 {
122 
123 int i,j,jtotal,k;
124 int zdate;
125 
126 /*
127  * EXEC SQL BEGIN DECLARE SECTION;
128  */
129 #line 12 "climo_search.ec"
130 #line 13 "climo_search.ec"
131 int edate, bdate;
132 int eyr, emo, edy;
133 int byr, bmo, bdy;
134 int etime, btime;
135 int year, month, day, ptime;
136  char pe1[2], pe2[2], dur[2], t[2], s[2], e[2], p[2], shb5[10];
137 struct bcavg
138  {
139  char id[6];
140  char pe1[2];
141  char pe2[2];
142  char dur[2];
143  char t[2];
144  char s[2];
145  char e[2];
146  char p[2];
147  double jan;
148  double feb;
149  double mar;
150  double apr;
151  double may;
152  double jun;
153  double jul;
154  double aug;
155  double sep;
156  double oct;
157  double nov;
158  double dec;
159  int datecalc;
160  } bcavg;
161 /*
162  * EXEC SQL END DECLARE SECTION;
163  */
164 #line 46 "climo_search.ec"
165 
166 
167 pe1[1]=0;
168 pe2[1]=0;
169 dur[1]=0;
170 t[1]=0;
171 s[1]=0;
172 e[1]=0;
173 p[1]=0;
174 
175 strcpy(shb5,hb5);
176 pe1[0]=parm[0];
177 pe2[0]=parm[1];
178 dur[0]=parm[2];
179 t[0]=parm[3];
180 s[0]=parm[4];
181 e[0]=parm[5];
182 p[0]=parm[6];
183 
184 jtotal=0;
185 
186 /*
187  * EXEC SQL select *
188  * into :bcavg
189  * from b_avg
190  * where id=:shb5 and
191  * pe1=:pe1 and
192  * pe2=:pe2 and
193  * dur=:dur and
194  * t=:t and
195  * s=:s and
196  * e=:e and
197  * p=:p ;
198  */
199 #line 67 "climo_search.ec"
200  {
201 #line 77 "climo_search.ec"
202  static const char *sqlcmdtxt[] =
203 #line 77 "climo_search.ec"
204  {
205 #line 77 "climo_search.ec"
206  "select * from b_avg where id = ? and pe1 = ? and pe2 = ? and dur = ? and t = ? and s = ? and e = ? and p = ?",
207  0
208  };
209 #line 77 "climo_search.ec"
210 static ifx_cursor_t _SQ0 = {0};
211  static ifx_sqlvar_t _sqibind[] =
212  {
213  { 100, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
214  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
215  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
216  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
217  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
218  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
219  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
220  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
221 #line 77 "climo_search.ec"
222  };
223  static ifx_sqlvar_t _sqobind[] =
224  {
225  { 100, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
226  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
227  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
228  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
229  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
230  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
231  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
232  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
233  { 105, sizeof((bcavg).jan), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
234  { 105, sizeof((bcavg).feb), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
235  { 105, sizeof((bcavg).mar), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
236  { 105, sizeof((bcavg).apr), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
237  { 105, sizeof((bcavg).may), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
238  { 105, sizeof((bcavg).jun), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
239  { 105, sizeof((bcavg).jul), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
240  { 105, sizeof((bcavg).aug), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
241  { 105, sizeof((bcavg).sep), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
242  { 105, sizeof((bcavg).oct), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
243  { 105, sizeof((bcavg).nov), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
244  { 105, sizeof((bcavg).dec), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
245  { 110, sizeof((bcavg).datecalc), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
246 #line 77 "climo_search.ec"
247  };
248 #line 77 "climo_search.ec"
249  _sqibind[0].sqldata = shb5;
250 #line 77 "climo_search.ec"
251  _sqibind[1].sqldata = pe1;
252 #line 77 "climo_search.ec"
253  _sqibind[2].sqldata = pe2;
254 #line 77 "climo_search.ec"
255  _sqibind[3].sqldata = dur;
256 #line 77 "climo_search.ec"
257  _sqibind[4].sqldata = t;
258 #line 77 "climo_search.ec"
259  _sqibind[5].sqldata = s;
260 #line 77 "climo_search.ec"
261  _sqibind[6].sqldata = e;
262 #line 77 "climo_search.ec"
263  _sqibind[7].sqldata = p;
264 #line 77 "climo_search.ec"
265  _sqobind[0].sqldata = (bcavg).id;
266 #line 77 "climo_search.ec"
267  _sqobind[1].sqldata = (bcavg).pe1;
268 #line 77 "climo_search.ec"
269  _sqobind[2].sqldata = (bcavg).pe2;
270 #line 77 "climo_search.ec"
271  _sqobind[3].sqldata = (bcavg).dur;
272 #line 77 "climo_search.ec"
273  _sqobind[4].sqldata = (bcavg).t;
274 #line 77 "climo_search.ec"
275  _sqobind[5].sqldata = (bcavg).s;
276 #line 77 "climo_search.ec"
277  _sqobind[6].sqldata = (bcavg).e;
278 #line 77 "climo_search.ec"
279  _sqobind[7].sqldata = (bcavg).p;
280 #line 77 "climo_search.ec"
281  _sqobind[8].sqldata = (char *) &(bcavg).jan;
282 #line 77 "climo_search.ec"
283  _sqobind[9].sqldata = (char *) &(bcavg).feb;
284 #line 77 "climo_search.ec"
285  _sqobind[10].sqldata = (char *) &(bcavg).mar;
286 #line 77 "climo_search.ec"
287  _sqobind[11].sqldata = (char *) &(bcavg).apr;
288 #line 77 "climo_search.ec"
289  _sqobind[12].sqldata = (char *) &(bcavg).may;
290 #line 77 "climo_search.ec"
291  _sqobind[13].sqldata = (char *) &(bcavg).jun;
292 #line 77 "climo_search.ec"
293  _sqobind[14].sqldata = (char *) &(bcavg).jul;
294 #line 77 "climo_search.ec"
295  _sqobind[15].sqldata = (char *) &(bcavg).aug;
296 #line 77 "climo_search.ec"
297  _sqobind[16].sqldata = (char *) &(bcavg).sep;
298 #line 77 "climo_search.ec"
299  _sqobind[17].sqldata = (char *) &(bcavg).oct;
300 #line 77 "climo_search.ec"
301  _sqobind[18].sqldata = (char *) &(bcavg).nov;
302 #line 77 "climo_search.ec"
303  _sqobind[19].sqldata = (char *) &(bcavg).dec;
304 #line 77 "climo_search.ec"
305  _sqobind[20].sqldata = (char *) &(bcavg).datecalc;
306 #line 77 "climo_search.ec"
307  sqli_slct(ESQLINTVERSION, &_SQ0,sqlcmdtxt,8,_sqibind,21,_sqobind,0,(ifx_literal_t *)0,(ifx_namelist_t *)0,0);
308 #line 77 "climo_search.ec"
309  }
310 
311  if(sqlca.sqlcode < 0)
312  return(sqlca.sqlcode);
313 
314  if(sqlca.sqlcode == 0) {
315 
316  stn_values[0].value=bcavg.jan;
317  stn_values[1].value=bcavg.feb;
318  stn_values[2].value=bcavg.mar;
319  stn_values[3].value=bcavg.apr;
320  stn_values[4].value=bcavg.may;
321  stn_values[5].value=bcavg.jun;
322  stn_values[6].value=bcavg.jul;
323  stn_values[7].value=bcavg.aug;
324  stn_values[8].value=bcavg.sep;
325  stn_values[9].value=bcavg.oct;
326  stn_values[10].value=bcavg.nov;
327  stn_values[11].value=bcavg.dec;
328 
329  for(k=0;k<12;k++) {
330 
331  stn_values[k].zdate=1970*10000+(k+1)*100 + 15;
332  stn_values[k].qual=0;
333 
334  }
335 
336  jtotal=12;
337 
338  }
339 
340 return(jtotal);
341 
342 }
343 
344 #line 110 "climo_search.ec"
int emo
Definition: calfma_qtrly.c:123
int bdy
Definition: calfma_qtrly.c:124
int eyr
Definition: calfma_qtrly.c:123
int edy
Definition: calfma_qtrly.c:123
int bmo
Definition: calfma_qtrly.c:124
int byr
Definition: calfma_qtrly.c:124
static int i
int climo_search(char *hb5, char *parm, struct stim begin_date, struct stim end_date, struct stn_values *stn_values)
Definition: climo_search.c:118
int4 SQLCODE
struct sqlca_s ifx_sqlca_t
char SQLSTATE[]
struct sqlca_s sqlca
int day
Definition: display_data.c:26
int year
Definition: display_data.c:26
int month
Definition: display_data.c:26
int j
Definition: mapp2h.h:48
int k
Definition: mapp2h.h:48
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:93
char qual
Definition: hydro_data.h:36
float value
Definition: hydro_data.h:35