Mapper
pro_monthly.c
Go to the documentation of this file.
1 #include <sqlhdr.h>
2 #include <sqliapi.h>
3 #line 1 "pro_monthly.ec"
4 #include "prototypes_new.h"
5 /*
6  * EXEC SQL include sqlca.h;
7  */
8 #line 2 "pro_monthly.ec"
9 
10 #line 2 "pro_monthly.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 "pro_monthly.ec"
117 
118 /*
119  * EXEC SQL BEGIN DECLARE SECTION;
120  */
121 #line 4 "pro_monthly.ec"
122 #line 5 "pro_monthly.ec"
123 int eyr, emo, edy;
124 int byr, bmo, bdy;
125 extern struct pro_monthly_rec
126  {
127  char id[6];
128  char pe1[2];
129  char pe2[2];
130  char dur[2];
131  char t[2];
132  char s[2];
133  char e[2];
134  char p[2];
135  int cal_yr;
136  double jan;
137  double feb;
138  double mar;
139  double apr;
140  double may;
141  double jun;
142  double jul;
143  double aug;
144  double sep;
145  double oct;
146  double nov;
147  double dec;
148  char janq[2];
149  char febq[2];
150  char marq[2];
151  char aprq[2];
152  char mayq[2];
153  char junq[2];
154  char julq[2];
155  char augq[2];
156  char sepq[2];
157  char octq[2];
158  char novq[2];
159  char decq[2];
161 /*
162  * EXEC SQL END DECLARE SECTION;
163  */
164 #line 47 "pro_monthly.ec"
165 
166 
167 extern struct data_rec {
168  char id[9];
169  char source[9];
170  char pe1;
171  char pe2;
172  char dur;
173  char t;
174  char s;
175  char e;
176  char p;
177  int zdate;
178  int ztime;
179  int czdate;
180  int cztime;
181  int idur;
182  double codp;
183  char lwal;
184  int idote;
185  int irev;
186  double value;
187  double values[96];
188  char lwals[96];
189  char pedtsep[8];
191 
192 int pro_monthly(char *hb5,char *parm,struct stim begin_date,struct stim
193 end_date, char *qual, struct stn_values *stn_values)
194 
195 {
196 
197 int i,jtotal,k,atime;
198 int etime,btime;
199 int hour,min;
200 int zdate,hh,qlen;
201 int numdays;
202 
203 /*
204  * EXEC SQL BEGIN DECLARE SECTION;
205  */
206 #line 85 "pro_monthly.ec"
207 #line 86 "pro_monthly.ec"
208 int edate, bdate;
209 int month, day, year;
210  char sparm[10];
211 struct stat
212  {
213  char hb5[6];
214  char pe1[2];
215  char pe2[2];
216  char dur[2];
217  char t[2];
218  char s[2];
219  char e[2];
220  char p[2];
221  } stat;
222 /*
223  * EXEC SQL END DECLARE SECTION;
224  */
225 #line 102 "pro_monthly.ec"
226 
227 
228 qlen=strlen(qual);
229 
230 stat.pe1[1]=0;
231 stat.pe2[1]=0;
232 stat.dur[1]=0;
233 stat.t[1]=0;
234 stat.s[1]=0;
235 stat.e[1]=0;
236 stat.p[1]=0;
237 
238 strcpy(stat.hb5,hb5);
239 stat.pe1[0]=parm[0];
240 stat.pe2[0]=parm[1];
241 stat.dur[0]=parm[2];
242 stat.t[0]=parm[3];
243 stat.s[0]=parm[4];
244 stat.e[0]=parm[5];
245 stat.p[0]=parm[6];
246 
247 eyr=end_date.year;
248 emo=end_date.month;
249 edy=end_date.day;
250 etime=end_date.hour*10000+
251  end_date.minute*100;
252 
253 byr=begin_date.year;
254 bmo=begin_date.month;
255 bdy=begin_date.day;
256 
257 year=byr;
258 month=bmo;
259 day=bdy;
260 
261 jtotal=0;
262 
263 for(;;) {
264 
265 /*
266  * EXEC SQL select *
267  * into :monthly_rec
268  * from promonly
269  * where id=:stat.hb5 and
270  * pe1=:stat.pe1 and
271  * pe2=:stat.pe2 and
272  * dur=:stat.dur and
273  * t=:stat.t and
274  * s=:stat.s and
275  * e=:stat.e and
276  * p=:stat.p and
277  * cal_yr=:year;
278  */
279 #line 141 "pro_monthly.ec"
280  {
281 #line 152 "pro_monthly.ec"
282  static const char *sqlcmdtxt[] =
283 #line 152 "pro_monthly.ec"
284  {
285 #line 152 "pro_monthly.ec"
286  "select * from promonly where id = ? and pe1 = ? and pe2 = ? and dur = ? and t = ? and s = ? and e = ? and p = ? and cal_yr = ?",
287  0
288  };
289 #line 152 "pro_monthly.ec"
290 static ifx_cursor_t _SQ0 = {0};
291  static ifx_sqlvar_t _sqibind[] =
292  {
293  { 100, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
294  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
295  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
296  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
297  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
298  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
299  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
300  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
301  { 102, sizeof(year), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
302 #line 152 "pro_monthly.ec"
303  };
304  static ifx_sqlvar_t _sqobind[] =
305  {
306  { 100, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
307  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
308  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
309  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
310  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
311  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
312  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
313  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
314  { 102, sizeof((monthly_rec).cal_yr), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
315  { 105, sizeof((monthly_rec).jan), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
316  { 105, sizeof((monthly_rec).feb), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
317  { 105, sizeof((monthly_rec).mar), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
318  { 105, sizeof((monthly_rec).apr), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
319  { 105, sizeof((monthly_rec).may), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
320  { 105, sizeof((monthly_rec).jun), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
321  { 105, sizeof((monthly_rec).jul), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
322  { 105, sizeof((monthly_rec).aug), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
323  { 105, sizeof((monthly_rec).sep), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
324  { 105, sizeof((monthly_rec).oct), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
325  { 105, sizeof((monthly_rec).nov), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
326  { 105, sizeof((monthly_rec).dec), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
327  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
328  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
329  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
330  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
331  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
332  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
333  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
334  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
335  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
336  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
337  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
338  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
339 #line 152 "pro_monthly.ec"
340  };
341 #line 152 "pro_monthly.ec"
342  _sqibind[0].sqldata = stat.hb5;
343 #line 152 "pro_monthly.ec"
344  _sqibind[1].sqldata = stat.pe1;
345 #line 152 "pro_monthly.ec"
346  _sqibind[2].sqldata = stat.pe2;
347 #line 152 "pro_monthly.ec"
348  _sqibind[3].sqldata = stat.dur;
349 #line 152 "pro_monthly.ec"
350  _sqibind[4].sqldata = stat.t;
351 #line 152 "pro_monthly.ec"
352  _sqibind[5].sqldata = stat.s;
353 #line 152 "pro_monthly.ec"
354  _sqibind[6].sqldata = stat.e;
355 #line 152 "pro_monthly.ec"
356  _sqibind[7].sqldata = stat.p;
357 #line 152 "pro_monthly.ec"
358  _sqibind[8].sqldata = (char *) &year;
359 #line 152 "pro_monthly.ec"
360  _sqobind[0].sqldata = (monthly_rec).id;
361 #line 152 "pro_monthly.ec"
362  _sqobind[1].sqldata = (monthly_rec).pe1;
363 #line 152 "pro_monthly.ec"
364  _sqobind[2].sqldata = (monthly_rec).pe2;
365 #line 152 "pro_monthly.ec"
366  _sqobind[3].sqldata = (monthly_rec).dur;
367 #line 152 "pro_monthly.ec"
368  _sqobind[4].sqldata = (monthly_rec).t;
369 #line 152 "pro_monthly.ec"
370  _sqobind[5].sqldata = (monthly_rec).s;
371 #line 152 "pro_monthly.ec"
372  _sqobind[6].sqldata = (monthly_rec).e;
373 #line 152 "pro_monthly.ec"
374  _sqobind[7].sqldata = (monthly_rec).p;
375 #line 152 "pro_monthly.ec"
376  _sqobind[8].sqldata = (char *) &(monthly_rec).cal_yr;
377 #line 152 "pro_monthly.ec"
378  _sqobind[9].sqldata = (char *) &(monthly_rec).jan;
379 #line 152 "pro_monthly.ec"
380  _sqobind[10].sqldata = (char *) &(monthly_rec).feb;
381 #line 152 "pro_monthly.ec"
382  _sqobind[11].sqldata = (char *) &(monthly_rec).mar;
383 #line 152 "pro_monthly.ec"
384  _sqobind[12].sqldata = (char *) &(monthly_rec).apr;
385 #line 152 "pro_monthly.ec"
386  _sqobind[13].sqldata = (char *) &(monthly_rec).may;
387 #line 152 "pro_monthly.ec"
388  _sqobind[14].sqldata = (char *) &(monthly_rec).jun;
389 #line 152 "pro_monthly.ec"
390  _sqobind[15].sqldata = (char *) &(monthly_rec).jul;
391 #line 152 "pro_monthly.ec"
392  _sqobind[16].sqldata = (char *) &(monthly_rec).aug;
393 #line 152 "pro_monthly.ec"
394  _sqobind[17].sqldata = (char *) &(monthly_rec).sep;
395 #line 152 "pro_monthly.ec"
396  _sqobind[18].sqldata = (char *) &(monthly_rec).oct;
397 #line 152 "pro_monthly.ec"
398  _sqobind[19].sqldata = (char *) &(monthly_rec).nov;
399 #line 152 "pro_monthly.ec"
400  _sqobind[20].sqldata = (char *) &(monthly_rec).dec;
401 #line 152 "pro_monthly.ec"
402  _sqobind[21].sqldata = (monthly_rec).janq;
403 #line 152 "pro_monthly.ec"
404  _sqobind[22].sqldata = (monthly_rec).febq;
405 #line 152 "pro_monthly.ec"
406  _sqobind[23].sqldata = (monthly_rec).marq;
407 #line 152 "pro_monthly.ec"
408  _sqobind[24].sqldata = (monthly_rec).aprq;
409 #line 152 "pro_monthly.ec"
410  _sqobind[25].sqldata = (monthly_rec).mayq;
411 #line 152 "pro_monthly.ec"
412  _sqobind[26].sqldata = (monthly_rec).junq;
413 #line 152 "pro_monthly.ec"
414  _sqobind[27].sqldata = (monthly_rec).julq;
415 #line 152 "pro_monthly.ec"
416  _sqobind[28].sqldata = (monthly_rec).augq;
417 #line 152 "pro_monthly.ec"
418  _sqobind[29].sqldata = (monthly_rec).sepq;
419 #line 152 "pro_monthly.ec"
420  _sqobind[30].sqldata = (monthly_rec).octq;
421 #line 152 "pro_monthly.ec"
422  _sqobind[31].sqldata = (monthly_rec).novq;
423 #line 152 "pro_monthly.ec"
424  _sqobind[32].sqldata = (monthly_rec).decq;
425 #line 152 "pro_monthly.ec"
426  sqli_slct(ESQLINTVERSION, &_SQ0,sqlcmdtxt,9,_sqibind,33,_sqobind,0,(ifx_literal_t *)0,(ifx_namelist_t *)0,0);
427 #line 152 "pro_monthly.ec"
428  }
429 
430  if(sqlca.sqlcode < 0)
431  return(sqlca.sqlcode);
432 
433  if(sqlca.sqlcode == 0) {
434 
435 
436  get_val12_array();
437 
438  for(k=12;k>=1;k--) {
439  day=1;
440 
441  zdate=monthly_rec.cal_yr*10000+k*100+30;
442 
443  if(year==eyr && k < emo)
444  break;
445 
446  if(year==byr && k > bmo)
447  continue;
448 
449  if(data_record.values[k] < -98)
450  continue;
451 
452  if(*qual != 0) {
453 
454  for(hh=0;hh<qlen;hh++)
455  if(*(qual+hh) == data_record.lwals[k])
456  break;
457 
458  if(hh==qlen)
459  continue;
460 
461  }
462 
464  stn_values[jtotal].zdate=zdate;
465  stn_values[jtotal].qual= data_record.lwals[k];
466 
467  stn_values[jtotal++].ztime=120000;
468 
469  }
470 
471 
472  }
473 
474  if(jtotal > 9600)
475  break;
476 
477  if(year==eyr)
478  break;
479 
480  year--;
481 
482  }
483 
484 return(jtotal);
485 
486 }
487 
489 {
490 
515 
516  return(0);
517 }
518 
519 
520 
521 #line 243 "pro_monthly.ec"
static int i
int hour
Definition: display_data.c:26
int day
Definition: display_data.c:26
int year
Definition: display_data.c:26
char qual[10]
Definition: subdisplay.c:33
int month
Definition: display_data.c:26
int k
Definition: mapp2h.h:48
int emo
Definition: pro_monthly.c:123
struct data_rec data_record
int bdy
Definition: pro_monthly.c:124
int get_val12_array()
Definition: pro_monthly.c:488
int eyr
Definition: pro_monthly.c:123
int edy
Definition: pro_monthly.c:123
int bmo
Definition: pro_monthly.c:124
int pro_monthly(char *hb5, char *parm, struct stim begin_date, struct stim end_date, char *qual, struct stn_values *stn_values)
Definition: pro_monthly.c:192
int4 SQLCODE
struct sqlca_s ifx_sqlca_t
char SQLSTATE[]
struct sqlca_s sqlca
int byr
Definition: pro_monthly.c:124
struct pro_monthly_rec monthly_rec
char source[9]
Definition: calfma_qtrly.c:162
double values[96]
Definition: calfma_qtrly.c:180
char lwals[96]
Definition: calfma_qtrly.c:181
char pedtsep[8]
Definition: calfma_qtrly.c:182
double codp
Definition: calfma_qtrly.c:175
double value
Definition: calfma_qtrly.c:179
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
int minute
Definition: misc.h:99
int day
Definition: misc.h:97
int year
Definition: misc.h:95
int hour
Definition: misc.h:98
int month
Definition: misc.h:96
char qual
Definition: hydro_data.h:36
float value
Definition: hydro_data.h:35