Mapper
pro_qtrly.c
Go to the documentation of this file.
1 #include <sqlhdr.h>
2 #include <sqliapi.h>
3 #line 1 "pro_qtrly.ec"
4 #include "prototypes_new.h"
5 /*
6  * EXEC SQL include sqlca.h;
7  */
8 #line 2 "pro_qtrly.ec"
9 
10 #line 2 "pro_qtrly.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_qtrly.ec"
117 
118 /*
119  * EXEC SQL BEGIN DECLARE SECTION;
120  */
121 #line 4 "pro_qtrly.ec"
122 #line 5 "pro_qtrly.ec"
123 int eyr, emo, edy;
124 int byr, bmo, bdy;
125 extern struct pro_qrtly_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  int mon;
137  int zday;
138  double z00;
139  double z06;
140  double z12;
141  double z18;
142  char qz00[2];
143  char qz06[2];
144  char qz12[2];
145  char qz18[2];
147 /*
148  * EXEC SQL END DECLARE SECTION;
149  */
150 #line 33 "pro_qtrly.ec"
151 
152 
153 extern struct data_rec {
154  char id[9];
155  char source[9];
156  char pe1;
157  char pe2;
158  char dur;
159  char t;
160  char s;
161  char e;
162  char p;
163  int zdate;
164  int ztime;
165  int czdate;
166  int cztime;
167  int idur;
168  double codp;
169  char lwal;
170  int idote;
171  int irev;
172  double value;
173  double values[96];
174  char lwals[96];
175  char pedtsep[8];
177 
179 
180 int pro_qtrly(char *hb5,char *parm,struct stim begin_date,struct stim
181 end_date, char *qual, struct stn_values *stn_values)
182 
183 {
184 
185 int i,jtotal,k,atime;
186 int etime,btime;
187 int hour,min;
188 int zdate,hh,qlen;
189 
190 /*
191  * EXEC SQL BEGIN DECLARE SECTION;
192  */
193 #line 72 "pro_qtrly.ec"
194 #line 73 "pro_qtrly.ec"
195 int edate, bdate;
196 int month, day, year;
197  char sparm[10];
198 struct stat
199  {
200  char hb5[6];
201  char pe1[2];
202  char pe2[2];
203  char dur[2];
204  char t[2];
205  char s[2];
206  char e[2];
207  char p[2];
208  } stat;
209 /*
210  * EXEC SQL END DECLARE SECTION;
211  */
212 #line 89 "pro_qtrly.ec"
213 
214 
215 
216 qlen=strlen(qual);
217 
218 stat.pe1[1]=0;
219 stat.pe2[1]=0;
220 stat.dur[1]=0;
221 stat.t[1]=0;
222 stat.s[1]=0;
223 stat.e[1]=0;
224 stat.p[1]=0;
225 
226 strcpy(stat.hb5,hb5);
227 stat.pe1[0]=parm[0];
228 stat.pe2[0]=parm[1];
229 stat.dur[0]=parm[2];
230 stat.t[0]=parm[3];
231 stat.s[0]=parm[4];
232 stat.e[0]=parm[5];
233 stat.p[0]=parm[6];
234 
235 eyr=end_date.year;
236 emo=end_date.month;
237 edy=end_date.day;
238 etime=end_date.hour*10000+
239  end_date.minute*100;
240 
241 byr=begin_date.year;
242 bmo=begin_date.month;
243 bdy=begin_date.day;
244 btime=begin_date.hour*10000+
245  begin_date.minute*100;
246 
247 year=byr;
248 month=bmo;
249 day=bdy;
250 
251 jtotal=0;
252 
253 for(;;) {
254 
255 /*
256  * EXEC SQL select *
257  * into :qtrly_rec
258  * from proqtrly
259  * where id=:stat.hb5 and
260  * pe1=:stat.pe1 and
261  * pe2=:stat.pe2 and
262  * dur=:stat.dur and
263  * t=:stat.t and
264  * s=:stat.s and
265  * e=:stat.e and
266  * p=:stat.p and
267  * cal_yr=:year and
268  * mon=:month and
269  * zday=:day
270  *
271  *
272  * ;
273  */
274 #line 131 "pro_qtrly.ec"
275  {
276 #line 147 "pro_qtrly.ec"
277  static const char *sqlcmdtxt[] =
278 #line 147 "pro_qtrly.ec"
279  {
280 #line 147 "pro_qtrly.ec"
281  "select * from proqtrly where id = ? and pe1 = ? and pe2 = ? and dur = ? and t = ? and s = ? and e = ? and p = ? and cal_yr = ? and mon = ? and zday = ?",
282  0
283  };
284 #line 147 "pro_qtrly.ec"
285 static ifx_cursor_t _SQ0 = {0};
286  static ifx_sqlvar_t _sqibind[] =
287  {
288  { 100, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
289  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
290  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
291  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
292  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
293  { 100, 2, 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  { 102, sizeof(year), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
297  { 102, sizeof(month), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
298  { 102, sizeof(day), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
299 #line 147 "pro_qtrly.ec"
300  };
301  static ifx_sqlvar_t _sqobind[] =
302  {
303  { 100, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
304  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
305  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
306  { 100, 2, 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  { 102, sizeof((qtrly_rec).cal_yr), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
312  { 102, sizeof((qtrly_rec).mon), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
313  { 102, sizeof((qtrly_rec).zday), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
314  { 105, sizeof((qtrly_rec).z00), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
315  { 105, sizeof((qtrly_rec).z06), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
316  { 105, sizeof((qtrly_rec).z12), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
317  { 105, sizeof((qtrly_rec).z18), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
318  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
319  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
320  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
321  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
322 #line 147 "pro_qtrly.ec"
323  };
324 #line 147 "pro_qtrly.ec"
325  _sqibind[0].sqldata = stat.hb5;
326 #line 147 "pro_qtrly.ec"
327  _sqibind[1].sqldata = stat.pe1;
328 #line 147 "pro_qtrly.ec"
329  _sqibind[2].sqldata = stat.pe2;
330 #line 147 "pro_qtrly.ec"
331  _sqibind[3].sqldata = stat.dur;
332 #line 147 "pro_qtrly.ec"
333  _sqibind[4].sqldata = stat.t;
334 #line 147 "pro_qtrly.ec"
335  _sqibind[5].sqldata = stat.s;
336 #line 147 "pro_qtrly.ec"
337  _sqibind[6].sqldata = stat.e;
338 #line 147 "pro_qtrly.ec"
339  _sqibind[7].sqldata = stat.p;
340 #line 147 "pro_qtrly.ec"
341  _sqibind[8].sqldata = (char *) &year;
342 #line 147 "pro_qtrly.ec"
343  _sqibind[9].sqldata = (char *) &month;
344 #line 147 "pro_qtrly.ec"
345  _sqibind[10].sqldata = (char *) &day;
346 #line 147 "pro_qtrly.ec"
347  _sqobind[0].sqldata = (qtrly_rec).id;
348 #line 147 "pro_qtrly.ec"
349  _sqobind[1].sqldata = (qtrly_rec).pe1;
350 #line 147 "pro_qtrly.ec"
351  _sqobind[2].sqldata = (qtrly_rec).pe2;
352 #line 147 "pro_qtrly.ec"
353  _sqobind[3].sqldata = (qtrly_rec).dur;
354 #line 147 "pro_qtrly.ec"
355  _sqobind[4].sqldata = (qtrly_rec).t;
356 #line 147 "pro_qtrly.ec"
357  _sqobind[5].sqldata = (qtrly_rec).s;
358 #line 147 "pro_qtrly.ec"
359  _sqobind[6].sqldata = (qtrly_rec).e;
360 #line 147 "pro_qtrly.ec"
361  _sqobind[7].sqldata = (qtrly_rec).p;
362 #line 147 "pro_qtrly.ec"
363  _sqobind[8].sqldata = (char *) &(qtrly_rec).cal_yr;
364 #line 147 "pro_qtrly.ec"
365  _sqobind[9].sqldata = (char *) &(qtrly_rec).mon;
366 #line 147 "pro_qtrly.ec"
367  _sqobind[10].sqldata = (char *) &(qtrly_rec).zday;
368 #line 147 "pro_qtrly.ec"
369  _sqobind[11].sqldata = (char *) &(qtrly_rec).z00;
370 #line 147 "pro_qtrly.ec"
371  _sqobind[12].sqldata = (char *) &(qtrly_rec).z06;
372 #line 147 "pro_qtrly.ec"
373  _sqobind[13].sqldata = (char *) &(qtrly_rec).z12;
374 #line 147 "pro_qtrly.ec"
375  _sqobind[14].sqldata = (char *) &(qtrly_rec).z18;
376 #line 147 "pro_qtrly.ec"
377  _sqobind[15].sqldata = (qtrly_rec).qz00;
378 #line 147 "pro_qtrly.ec"
379  _sqobind[16].sqldata = (qtrly_rec).qz06;
380 #line 147 "pro_qtrly.ec"
381  _sqobind[17].sqldata = (qtrly_rec).qz12;
382 #line 147 "pro_qtrly.ec"
383  _sqobind[18].sqldata = (qtrly_rec).qz18;
384 #line 147 "pro_qtrly.ec"
385  sqli_slct(ESQLINTVERSION, &_SQ0,sqlcmdtxt,11,_sqibind,19,_sqobind,0,(ifx_literal_t *)0,(ifx_namelist_t *)0,0);
386 #line 147 "pro_qtrly.ec"
387  }
388 
389  if(sqlca.sqlcode < 0)
390  return(sqlca.sqlcode);
391 
392  if(sqlca.sqlcode == 0) {
393 
394  get_val06_array();
395 
396  for(k=3;k>=0;k--) {
397 
398  hour=k;
399  atime=hour*60000;
400  zdate=qtrly_rec.cal_yr*10000+qtrly_rec.mon*100+qtrly_rec.zday;
401 
402  if(year==eyr && month==emo && day==edy &&
403  atime < etime)
404  break;
405 
406  if(year==byr && month==bmo && day==bdy &&
407  atime > btime)
408  continue;
409 
410  if(data_record.values[k] < -98)
411  continue;
412 
413  if(*qual != 0) {
414 
415  for(hh=0;hh<qlen;hh++)
416  if(*(qual+hh) == data_record.lwals[k])
417  break;
418 
419  if(hh==qlen)
420  continue;
421 
422  }
423 
425  stn_values[jtotal].zdate=zdate;
426  stn_values[jtotal].qual= data_record.lwals[k];
427 
428  stn_values[jtotal++].ztime=atime;
429 
430  }
431 
432 
433  }
434 
435  if(jtotal > 9600)
436  break;
437 
438  if(year==eyr && month==emo && day==edy)
439  break;
440 
442 
443  }
444 
445 return(jtotal);
446 
447 }
448 
450 {
451 
460 
461  return(0);
462 }
463 
464 void change_dateq(int *year,int *month, int*day)
465 
466 {
467 
468 extern int mday[];
469 
470 char buf[10];
471 XmString btn_text;
472 Arg args[10];
473 
474 if (!((*year)%4))
475  mday[1]=29;
476 else
477  mday[1]=28;
478 
479 /*
480 if ((*year)==1972 || (*year)==1976 || (*year)==1980 ||
481  (*year)==1984 || (*year)==1988 || (*year)==1992 ||
482  (*year)==1996 || (*year)==2000 || (*year)==2004 ||
483  (*year)==2008 || (*year)==2012 || (*year)==2016)
484  mday[1]=29;
485 else
486  mday[1]=28;
487 */
488 
489 (*day)--;
490 
491 if(*day <= 0) {
492 
493  (*month)--;
494  if(*month==0) {
495 
496  (*year)--;
497  *month=12;
498 
499  }
500 
501  *day=mday[*month-1];
502 
503  }
504 
505 else if(*day > mday[*month-1]) {
506 
507  *(month)++;
508 
509  if(*month > 12) {
510 
511  (*year)++;
512  *month=1;
513 
514  }
515 
516  *day=1;
517 
518  }
519 
520 
521 }
522 
523 
524 
525 #line 283 "pro_qtrly.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 mday[]
Definition: fmap_qtrly.c:519
char * mon[]
struct stat buf
Definition: is_file_closed.c:8
int k
Definition: mapp2h.h:48
Arg args[10]
int get_val06_array()
Definition: pro_qtrly.c:449
int emo
Definition: pro_qtrly.c:123
struct data_rec data_record
int bdy
Definition: pro_qtrly.c:124
int eyr
Definition: pro_qtrly.c:123
int edy
Definition: pro_qtrly.c:123
int bmo
Definition: pro_qtrly.c:124
int4 SQLCODE
struct sqlca_s ifx_sqlca_t
struct pro_qrtly_rec qtrly_rec
char SQLSTATE[]
struct sqlca_s sqlca
int byr
Definition: pro_qtrly.c:124
int pro_qtrly(char *hb5, char *parm, struct stim begin_date, struct stim end_date, char *qual, struct stn_values *stn_values)
Definition: pro_qtrly.c:180
void change_dateq()
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 s[2]
Definition: pro_qtrly.c:132
char pe1[2]
Definition: pro_qtrly.c:128
char p[2]
Definition: pro_qtrly.c:134
char dur[2]
Definition: pro_qtrly.c:130
double z00
Definition: pro_qtrly.c:138
double z18
Definition: pro_qtrly.c:141
char qz12[2]
Definition: pro_qtrly.c:144
char qz06[2]
Definition: pro_qtrly.c:143
char pe2[2]
Definition: pro_qtrly.c:129
char e[2]
Definition: pro_qtrly.c:133
double z06
Definition: pro_qtrly.c:139
char t[2]
Definition: pro_qtrly.c:131
char qz00[2]
Definition: pro_qtrly.c:142
double z12
Definition: pro_qtrly.c:140
char qz18[2]
Definition: pro_qtrly.c:145
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