Daily_QC
candidate.c
Go to the documentation of this file.
1 #include <sqlhdr.h>
2 extern _SQCURSOR *_iqnprep();
3 
4 #if !defined(__STDC__)
5 #define const
6 #endif
7 
8 static const char *_Cn1 = "stncursor"; static _SQCURSOR *_SQ1 = 0;
9 #line 1 "candidate.ec"
10 #include "prototypes.h"
11 /*
12  * EXEC SQL include sqlca.h;
13  */
14 #line 2 "candidate.ec"
15 #line 1 "/usr/informix/incl/esql/sqlca.h"
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 #ifndef SQLCA_INCL
42 
43 #define SQLCA_INCL
44 
45 struct sqlca_s
46  {
47  long sqlcode;
48  char sqlerrm[72];
49  char sqlerrp[8];
50  long sqlerrd[6];
51 
52 
53 
54 
55 
56 
57  struct sqlcaw_s
58  {
59  char sqlwarn0;
60  char sqlwarn1;
61 
62  char sqlwarn2;
63 
64  char sqlwarn3;
65 
66  char sqlwarn4;
67 
68  char sqlwarn5;
69  char sqlwarn6;
70  char sqlwarn7;
71  } sqlwarn;
72  };
73 
74 
75 
76 
77 
78 
79 
80 
81 
82 #ifdef VMS
83 noshare
84 #endif
85 extern struct sqlca_s sqlca;
86 
87 extern long SQLCODE;
88 
89 #define SQLNOTFOUND 100
90 
91 #endif
92 #line 3 "candidate.ec"
93 
94 /*
95  * EXEC SQL BEGIN DECLARE SECTION;
96  */
97 #line 4 "candidate.ec"
98 
99 char t, s, pe1, pe2, dur;
100 struct etn_rec
101  {
102  char id[6];
103  char plat[9];
104  char des[51];
105  char det[41];
106  char init[9];
107  char lat[7];
108  char lng[8];
109  int elev;
110  char stat[3];
111  char huc[9];
112  char cou[4];
113  char zon[5];
114  char hsa[4];
115  char cwa[4];
116  int post;
117  char dbsource[4];
119 struct gage_info
120  {
121  char id[6];
122  char pe1[2];
123  char pe2[2];
124  char dur[2];
125  char t[2];
126  char s[2];
127  char e[2];
128  char p[2];
129  char mode[2];
130  } info;
131 struct pro_hrly_rec
132  {
133  char id[6];
134  char pe1[2];
135  char pe2[2];
136  char dur[2];
137  char t[2];
138  char s[2];
139  char e[2];
140  char p[2];
141  int cal_yr;
142  int mon;
143  int zday;
144  double zhr00;
145  double zhr01;
146  double zhr02;
147  double zhr03;
148  double zhr04;
149  double zhr05;
150  double zhr06;
151  double zhr07;
152  double zhr08;
153  double zhr09;
154  double zhr10;
155  double zhr11;
156  double zhr12;
157  double zhr13;
158  double zhr14;
159  double zhr15;
160  double zhr16;
161  double zhr17;
162  double zhr18;
163  double zhr19;
164  double zhr20;
165  double zhr21;
166  double zhr22;
167  double zhr23;
168  char qzhr00[2];
169  char qzhr01[2];
170  char qzhr02[2];
171  char qzhr03[2];
172  char qzhr04[2];
173  char qzhr05[2];
174  char qzhr06[2];
175  char qzhr07[2];
176  char qzhr08[2];
177  char qzhr09[2];
178  char qzhr10[2];
179  char qzhr11[2];
180  char qzhr12[2];
181  char qzhr13[2];
182  char qzhr14[2];
183  char qzhr15[2];
184  char qzhr16[2];
185  char qzhr17[2];
186  char qzhr18[2];
187  char qzhr19[2];
188  char qzhr20[2];
189  char qzhr21[2];
190  char qzhr22[2];
191  char qzhr23[2];
193 struct pro_dly_rec
194  {
195  char id[6];
196  char pe1[2];
197  char pe2[2];
198  char dur[2];
199  char t[2];
200  char s[2];
201  char e[2];
202  char p[2];
203  int cal_yr;
204  int mon;
205  double zday01;
206  double zday02;
207  double zday03;
208  double zday04;
209  double zday05;
210  double zday06;
211  double zday07;
212  double zday08;
213  double zday09;
214  double zday10;
215  double zday11;
216  double zday12;
217  double zday13;
218  double zday14;
219  double zday15;
220  double zday16;
221  double zday17;
222  double zday18;
223  double zday19;
224  double zday20;
225  double zday21;
226  double zday22;
227  double zday23;
228  double zday24;
229  double zday25;
230  double zday26;
231  double zday27;
232  double zday28;
233  double zday29;
234  double zday30;
235  double zday31;
236  char qzday01[2];
237  char qzday02[2];
238  char qzday03[2];
239  char qzday04[2];
240  char qzday05[2];
241  char qzday06[2];
242  char qzday07[2];
243  char qzday08[2];
244  char qzday09[2];
245  char qzday10[2];
246  char qzday11[2];
247  char qzday12[2];
248  char qzday13[2];
249  char qzday14[2];
250  char qzday15[2];
251  char qzday16[2];
252  char qzday17[2];
253  char qzday18[2];
254  char qzday19[2];
255  char qzday20[2];
256  char qzday21[2];
257  char qzday22[2];
258  char qzday23[2];
259  char qzday24[2];
260  char qzday25[2];
261  char qzday26[2];
262  char qzday27[2];
263  char qzday28[2];
264  char qzday29[2];
265  char qzday30[2];
266  char qzday31[2];
268 struct eens_rec
269  {
270  char id[6];
271  char pe1[2];
272  char pe2[2];
273  char dur[2];
274  char t[2];
275  char s[2];
276  char e[2];
277  char p[2];
278  char type[2];
279  char des[51];
280  char det[41];
281  int post;
282  char new_report[2];
283  char active[2];
284  char rfs[2];
285  int obstime;
286  char prod[10];
287  char prod2ary[10];
288  char obsag[7];
289  char obsloc[4];
290  char prov_avail[2];
291  char final_avail[8];
292  char ownag[7];
293  char ownloc[4];
294  char maintag[7];
295  char maintloc[4];
296  char init[9];
297  char dbsource[4];
299 /*
300  * EXEC SQL END DECLARE SECTION;
301  */
302 #line 216 "candidate.ec"
303 
304 
305 struct data_rec {
306  char id[9];
307  char source[9];
308  char pe1;
309  char pe2;
310  char dur;
311  char t;
312  char s;
313  char e;
314  char p;
315  int zdate;
316  int ztime;
317  int czdate;
318  int cztime;
319  int idur;
320  double codp;
321  char lwal;
322  int idote;
323  int irev;
324  double value;
325  double values[96];
326  char lwals[96];
327  char pedtsep[8];
329 int mday[]={31,28,31,30,31,30,31,31,30,31,30,31} ;
330 void main(int argc, char **argv)
331 
332 {
333 struct stn_values *dtn_values;
334 struct stn_values *qtn_values;
335 time_t tim,tim1;
336 struct tm *gmtim;
337 struct tm *ltim;
338 int i,j,h;
339 struct stim btim;
340 struct stim etim;
341 struct stim btim1;
342 struct stim etim1;
343 struct stim etim2;
344 char oldstat[10];
345 char *s[5];
346 FILE *fp;
347 char pc[10];
348 char qual[10];
349 int k;
350 char mbuf[100];
351 char dbuf[80],ts1[80];
352 char ozon[20];
353 char zbuf[1000],abuf[100];
354 char name[60];
355 int zdate[10],ztime[10];
356 int bflag;
357 char *add,file[50],*key;
358 int maxdays;
359 time_t itime[20];
360 int qtotal,dtotal;
361 extern int optind,opterr,optopt;
362 extern char *optarg;
363 int c;
364 char *p,*q;
365 int month,day,year,hour,idflag;
366 char *directory,fname[50];
367 int fflag;
368 time_t tim2;
369 int qual_flag;
370 char qbuf[10];
371 double flng,flat;
372 int itemp,itemp1,itemp2,ival,len;
373 int l,ii;
374 int tip;
375 
376 t='1';
377 fp=fopen("junkfile","w");
378 
379 qbuf[1]=0;
380 
381 strcpy(qual,"SF");
382 qual_flag=0;
383 maxdays=100;
384 
385 while((c=getopt(argc,argv,"d:h:n:f:q:v"))!=-1){
386 
387  switch(c) {
388 
389  case 'f':
390 
391  strcpy(fname,optarg);
392  fflag=1;
393  break;
394 
395 
396  default:
397 
398  exit(1);
399 
400  }
401 
402  }
403 
405 
406 dtn_values=calloc(1000,sizeof(struct stn_values));
407 qtn_values=calloc(1000,sizeof(struct stn_values));
408 
409 
410 tim=time(NULL);
411 gmtim=gmtime(&tim);
412 btim.year=gmtim->tm_year+1900;
413 btim.month=gmtim->tm_mon+1;
414 btim.day=gmtim->tm_mday;
415 btim.hour=gmtim->tm_hour;
416 btim.minute=0;
417 
418 tim1=tim-(maxdays-1)*86400L;
419 gmtim=gmtime(&tim1);
420 
421 etim.year=gmtim->tm_year+1900;
422 etim.month=gmtim->tm_mon+1;
423 etim.day=gmtim->tm_mday;
424 etim.hour=12;
425 etim.minute=0;
426 
427 tim1=tim-maxdays*86400L;
428 gmtim=gmtime(&tim1);
429 
430 etim2.year=gmtim->tm_year+1900;
431 etim2.month=gmtim->tm_mon+1;
432 etim2.day=gmtim->tm_mday;
433 etim2.hour=12;
434 etim2.minute=0;
435 
436 /*
437  * EXEC SQL open stncursor;
438  */
439 #line 349 "candidate.ec"
440  {
441 #line 349 "candidate.ec"
442 #line 349 "candidate.ec"
443  _SQ1 = _iqlocate_cursor(_Cn1, 0, 0);
444 #line 349 "candidate.ec"
445  _iqdcopen(_SQ1, (struct sqlda *)0, (char *)0, (char *)0, 0);
446 #line 349 "candidate.ec"
447  }
448 
449 if(sqlca.sqlcode < 0){
450 
451  printf("informix error %d\n",sqlca.sqlcode);
452  exit(1);
453 
454  }
455 
456 for(i=0;i<5000;i++) {
457 
458  mbuf[0]=0;
459 
460  bflag=0;
461 /*
462  * EXEC SQL fetch stncursor into :btn_rec;
463  */
464 #line 363 "candidate.ec"
465  {
466 #line 363 "candidate.ec"
467  static struct sqlvar_struct _sqobind[] =
468  {
469  { 100, 6, 0, 0, 0, 0, 0, 0, 0 },
470  { 100, 9, 0, 0, 0, 0, 0, 0, 0 },
471  { 100, 51, 0, 0, 0, 0, 0, 0, 0 },
472  { 100, 41, 0, 0, 0, 0, 0, 0, 0 },
473  { 100, 9, 0, 0, 0, 0, 0, 0, 0 },
474  { 100, 7, 0, 0, 0, 0, 0, 0, 0 },
475  { 100, 8, 0, 0, 0, 0, 0, 0, 0 },
476  { 102, sizeof((btn_rec).elev), 0, 0, 0, 0, 0, 0, 0 },
477  { 100, 3, 0, 0, 0, 0, 0, 0, 0 },
478  { 100, 9, 0, 0, 0, 0, 0, 0, 0 },
479  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
480  { 100, 5, 0, 0, 0, 0, 0, 0, 0 },
481  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
482  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
483  { 102, sizeof((btn_rec).post), 0, 0, 0, 0, 0, 0, 0 },
484  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
485 #line 363 "candidate.ec"
486  };
487  static struct sqlda _SD0 = { 16, _sqobind, 0, 16, 0 };
488  static _FetchSpec _FS1 = { 0, 1, 0 };
489 #line 363 "candidate.ec"
490  _sqobind[0].sqldata = (btn_rec).id;
491 #line 363 "candidate.ec"
492  _sqobind[1].sqldata = (btn_rec).plat;
493 #line 363 "candidate.ec"
494  _sqobind[2].sqldata = (btn_rec).des;
495 #line 363 "candidate.ec"
496  _sqobind[3].sqldata = (btn_rec).det;
497 #line 363 "candidate.ec"
498  _sqobind[4].sqldata = (btn_rec).init;
499 #line 363 "candidate.ec"
500  _sqobind[5].sqldata = (btn_rec).lat;
501 #line 363 "candidate.ec"
502  _sqobind[6].sqldata = (btn_rec).lng;
503 #line 363 "candidate.ec"
504  _sqobind[7].sqldata = (char *) &(btn_rec).elev;
505 #line 363 "candidate.ec"
506  _sqobind[8].sqldata = (btn_rec).stat;
507 #line 363 "candidate.ec"
508  _sqobind[9].sqldata = (btn_rec).huc;
509 #line 363 "candidate.ec"
510  _sqobind[10].sqldata = (btn_rec).cou;
511 #line 363 "candidate.ec"
512  _sqobind[11].sqldata = (btn_rec).zon;
513 #line 363 "candidate.ec"
514  _sqobind[12].sqldata = (btn_rec).hsa;
515 #line 363 "candidate.ec"
516  _sqobind[13].sqldata = (btn_rec).cwa;
517 #line 363 "candidate.ec"
518  _sqobind[14].sqldata = (char *) &(btn_rec).post;
519 #line 363 "candidate.ec"
520  _sqobind[15].sqldata = (btn_rec).dbsource;
521 #line 363 "candidate.ec"
522  _SQ1 = _iqlocate_cursor(_Cn1, 0, 0);
523 #line 363 "candidate.ec"
524  _iqcftch(_SQ1, (struct sqlda *)0, &_SD0, (char *)0, &_FS1);
525 #line 363 "candidate.ec"
526  }
527 
528  if(sqlca.sqlcode < 0){
529 
530  printf("informix error %d\n",sqlca.sqlcode);
531  exit(1);
532 
533  }
534 
535  if(sqlca.sqlcode != 0)
536  break;
537 
538  for(l=0;l<5;l++) {
539 
540  if(l==0) {
541 
542 /*
543  * EXEC SQL select *
544  * into :bens_rec
545  * from sens
546  * where id=:btn_rec.id and
547  * pe1='P' and
548  * pe2='P' and
549  * dur='D' and
550  * t=:t and
551  * s='P' and
552  * e='Z' and
553  * p='Z';
554  */
555 #line 379 "candidate.ec"
556  {
557 #line 379 "candidate.ec"
558  static const char *sqlcmdtxt[] =
559 #line 379 "candidate.ec"
560  {
561 #line 379 "candidate.ec"
562  " select * from sens where id = ? and pe1 = 'P' and pe2 = 'P' and dur = 'D' and t = ? and s = 'P' and e = 'Z' and p = 'Z'",
563  0
564  };
565 #line 389 "candidate.ec"
566  static _SQCURSOR _SQ0 = {0};
567  static struct sqlvar_struct _sqibind[] =
568  {
569  { 100, 6, 0, 0, 0, 0, 0, 0, 0 },
570  { 108, 1, 0, 0, 0, 0, 0, 0, 0 },
571 #line 389 "candidate.ec"
572  };
573  static struct sqlvar_struct _sqobind[] =
574  {
575  { 100, 6, 0, 0, 0, 0, 0, 0, 0 },
576  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
577  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
578  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
579  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
580  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
581  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
582  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
583  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
584  { 100, 51, 0, 0, 0, 0, 0, 0, 0 },
585  { 100, 41, 0, 0, 0, 0, 0, 0, 0 },
586  { 102, sizeof((bens_rec).post), 0, 0, 0, 0, 0, 0, 0 },
587  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
588  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
589  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
590  { 102, sizeof((bens_rec).obstime), 0, 0, 0, 0, 0, 0, 0 },
591  { 100, 10, 0, 0, 0, 0, 0, 0, 0 },
592  { 100, 10, 0, 0, 0, 0, 0, 0, 0 },
593  { 100, 7, 0, 0, 0, 0, 0, 0, 0 },
594  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
595  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
596  { 100, 8, 0, 0, 0, 0, 0, 0, 0 },
597  { 100, 7, 0, 0, 0, 0, 0, 0, 0 },
598  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
599  { 100, 7, 0, 0, 0, 0, 0, 0, 0 },
600  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
601  { 100, 9, 0, 0, 0, 0, 0, 0, 0 },
602  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
603 #line 389 "candidate.ec"
604  };
605 #line 389 "candidate.ec"
606  _sqibind[0].sqldata = btn_rec.id;
607 #line 389 "candidate.ec"
608  _sqibind[1].sqldata = &t;
609 #line 389 "candidate.ec"
610  _sqobind[0].sqldata = (bens_rec).id;
611 #line 389 "candidate.ec"
612  _sqobind[1].sqldata = (bens_rec).pe1;
613 #line 389 "candidate.ec"
614  _sqobind[2].sqldata = (bens_rec).pe2;
615 #line 389 "candidate.ec"
616  _sqobind[3].sqldata = (bens_rec).dur;
617 #line 389 "candidate.ec"
618  _sqobind[4].sqldata = (bens_rec).t;
619 #line 389 "candidate.ec"
620  _sqobind[5].sqldata = (bens_rec).s;
621 #line 389 "candidate.ec"
622  _sqobind[6].sqldata = (bens_rec).e;
623 #line 389 "candidate.ec"
624  _sqobind[7].sqldata = (bens_rec).p;
625 #line 389 "candidate.ec"
626  _sqobind[8].sqldata = (bens_rec).type;
627 #line 389 "candidate.ec"
628  _sqobind[9].sqldata = (bens_rec).des;
629 #line 389 "candidate.ec"
630  _sqobind[10].sqldata = (bens_rec).det;
631 #line 389 "candidate.ec"
632  _sqobind[11].sqldata = (char *) &(bens_rec).post;
633 #line 389 "candidate.ec"
634  _sqobind[12].sqldata = (bens_rec).new_report;
635 #line 389 "candidate.ec"
636  _sqobind[13].sqldata = (bens_rec).active;
637 #line 389 "candidate.ec"
638  _sqobind[14].sqldata = (bens_rec).rfs;
639 #line 389 "candidate.ec"
640  _sqobind[15].sqldata = (char *) &(bens_rec).obstime;
641 #line 389 "candidate.ec"
642  _sqobind[16].sqldata = (bens_rec).prod;
643 #line 389 "candidate.ec"
644  _sqobind[17].sqldata = (bens_rec).prod2ary;
645 #line 389 "candidate.ec"
646  _sqobind[18].sqldata = (bens_rec).obsag;
647 #line 389 "candidate.ec"
648  _sqobind[19].sqldata = (bens_rec).obsloc;
649 #line 389 "candidate.ec"
650  _sqobind[20].sqldata = (bens_rec).prov_avail;
651 #line 389 "candidate.ec"
652  _sqobind[21].sqldata = (bens_rec).final_avail;
653 #line 389 "candidate.ec"
654  _sqobind[22].sqldata = (bens_rec).ownag;
655 #line 389 "candidate.ec"
656  _sqobind[23].sqldata = (bens_rec).ownloc;
657 #line 389 "candidate.ec"
658  _sqobind[24].sqldata = (bens_rec).maintag;
659 #line 389 "candidate.ec"
660  _sqobind[25].sqldata = (bens_rec).maintloc;
661 #line 389 "candidate.ec"
662  _sqobind[26].sqldata = (bens_rec).init;
663 #line 389 "candidate.ec"
664  _sqobind[27].sqldata = (bens_rec).dbsource;
665 #line 389 "candidate.ec"
666  _iqslct(&_SQ0, sqlcmdtxt, 2, _sqibind, 28, _sqobind, 0);
667 #line 389 "candidate.ec"
668  }
669 
670  }
671 
672 
673  else if(l==1) {
674 
675 /*
676  * EXEC SQL select *
677  * into :bens_rec
678  * from sens
679  * where id=:btn_rec.id and
680  * pe1='P' and
681  * pe2='P' and
682  * dur='D' and
683  * t=:t and
684  * s='G' and
685  * e='Z' and
686  * p='Z';
687  */
688 #line 396 "candidate.ec"
689  {
690 #line 396 "candidate.ec"
691  static const char *sqlcmdtxt[] =
692 #line 396 "candidate.ec"
693  {
694 #line 396 "candidate.ec"
695  " select * from sens where id = ? and pe1 = 'P' and pe2 = 'P' and dur = 'D' and t = ? and s = 'G' and e = 'Z' and p = 'Z'",
696  0
697  };
698 #line 406 "candidate.ec"
699  static _SQCURSOR _SQ0 = {0};
700  static struct sqlvar_struct _sqibind[] =
701  {
702  { 100, 6, 0, 0, 0, 0, 0, 0, 0 },
703  { 108, 1, 0, 0, 0, 0, 0, 0, 0 },
704 #line 406 "candidate.ec"
705  };
706  static struct sqlvar_struct _sqobind[] =
707  {
708  { 100, 6, 0, 0, 0, 0, 0, 0, 0 },
709  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
710  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
711  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
712  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
713  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
714  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
715  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
716  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
717  { 100, 51, 0, 0, 0, 0, 0, 0, 0 },
718  { 100, 41, 0, 0, 0, 0, 0, 0, 0 },
719  { 102, sizeof((bens_rec).post), 0, 0, 0, 0, 0, 0, 0 },
720  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
721  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
722  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
723  { 102, sizeof((bens_rec).obstime), 0, 0, 0, 0, 0, 0, 0 },
724  { 100, 10, 0, 0, 0, 0, 0, 0, 0 },
725  { 100, 10, 0, 0, 0, 0, 0, 0, 0 },
726  { 100, 7, 0, 0, 0, 0, 0, 0, 0 },
727  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
728  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
729  { 100, 8, 0, 0, 0, 0, 0, 0, 0 },
730  { 100, 7, 0, 0, 0, 0, 0, 0, 0 },
731  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
732  { 100, 7, 0, 0, 0, 0, 0, 0, 0 },
733  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
734  { 100, 9, 0, 0, 0, 0, 0, 0, 0 },
735  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
736 #line 406 "candidate.ec"
737  };
738 #line 406 "candidate.ec"
739  _sqibind[0].sqldata = btn_rec.id;
740 #line 406 "candidate.ec"
741  _sqibind[1].sqldata = &t;
742 #line 406 "candidate.ec"
743  _sqobind[0].sqldata = (bens_rec).id;
744 #line 406 "candidate.ec"
745  _sqobind[1].sqldata = (bens_rec).pe1;
746 #line 406 "candidate.ec"
747  _sqobind[2].sqldata = (bens_rec).pe2;
748 #line 406 "candidate.ec"
749  _sqobind[3].sqldata = (bens_rec).dur;
750 #line 406 "candidate.ec"
751  _sqobind[4].sqldata = (bens_rec).t;
752 #line 406 "candidate.ec"
753  _sqobind[5].sqldata = (bens_rec).s;
754 #line 406 "candidate.ec"
755  _sqobind[6].sqldata = (bens_rec).e;
756 #line 406 "candidate.ec"
757  _sqobind[7].sqldata = (bens_rec).p;
758 #line 406 "candidate.ec"
759  _sqobind[8].sqldata = (bens_rec).type;
760 #line 406 "candidate.ec"
761  _sqobind[9].sqldata = (bens_rec).des;
762 #line 406 "candidate.ec"
763  _sqobind[10].sqldata = (bens_rec).det;
764 #line 406 "candidate.ec"
765  _sqobind[11].sqldata = (char *) &(bens_rec).post;
766 #line 406 "candidate.ec"
767  _sqobind[12].sqldata = (bens_rec).new_report;
768 #line 406 "candidate.ec"
769  _sqobind[13].sqldata = (bens_rec).active;
770 #line 406 "candidate.ec"
771  _sqobind[14].sqldata = (bens_rec).rfs;
772 #line 406 "candidate.ec"
773  _sqobind[15].sqldata = (char *) &(bens_rec).obstime;
774 #line 406 "candidate.ec"
775  _sqobind[16].sqldata = (bens_rec).prod;
776 #line 406 "candidate.ec"
777  _sqobind[17].sqldata = (bens_rec).prod2ary;
778 #line 406 "candidate.ec"
779  _sqobind[18].sqldata = (bens_rec).obsag;
780 #line 406 "candidate.ec"
781  _sqobind[19].sqldata = (bens_rec).obsloc;
782 #line 406 "candidate.ec"
783  _sqobind[20].sqldata = (bens_rec).prov_avail;
784 #line 406 "candidate.ec"
785  _sqobind[21].sqldata = (bens_rec).final_avail;
786 #line 406 "candidate.ec"
787  _sqobind[22].sqldata = (bens_rec).ownag;
788 #line 406 "candidate.ec"
789  _sqobind[23].sqldata = (bens_rec).ownloc;
790 #line 406 "candidate.ec"
791  _sqobind[24].sqldata = (bens_rec).maintag;
792 #line 406 "candidate.ec"
793  _sqobind[25].sqldata = (bens_rec).maintloc;
794 #line 406 "candidate.ec"
795  _sqobind[26].sqldata = (bens_rec).init;
796 #line 406 "candidate.ec"
797  _sqobind[27].sqldata = (bens_rec).dbsource;
798 #line 406 "candidate.ec"
799  _iqslct(&_SQ0, sqlcmdtxt, 2, _sqibind, 28, _sqobind, 0);
800 #line 406 "candidate.ec"
801  }
802 
803  }
804 
805 
806  else if(l==2) {
807 
808 /*
809  * EXEC SQL select *
810  * into :bens_rec
811  * from sens
812  * where id=:btn_rec.id and
813  * pe1='P' and
814  * pe2='P' and
815  * dur='D' and
816  * t=:t and
817  * s='M' and
818  * e='Z' and
819  * p='Z';
820  */
821 #line 413 "candidate.ec"
822  {
823 #line 413 "candidate.ec"
824  static const char *sqlcmdtxt[] =
825 #line 413 "candidate.ec"
826  {
827 #line 413 "candidate.ec"
828  " select * from sens where id = ? and pe1 = 'P' and pe2 = 'P' and dur = 'D' and t = ? and s = 'M' and e = 'Z' and p = 'Z'",
829  0
830  };
831 #line 423 "candidate.ec"
832  static _SQCURSOR _SQ0 = {0};
833  static struct sqlvar_struct _sqibind[] =
834  {
835  { 100, 6, 0, 0, 0, 0, 0, 0, 0 },
836  { 108, 1, 0, 0, 0, 0, 0, 0, 0 },
837 #line 423 "candidate.ec"
838  };
839  static struct sqlvar_struct _sqobind[] =
840  {
841  { 100, 6, 0, 0, 0, 0, 0, 0, 0 },
842  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
843  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
844  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
845  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
846  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
847  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
848  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
849  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
850  { 100, 51, 0, 0, 0, 0, 0, 0, 0 },
851  { 100, 41, 0, 0, 0, 0, 0, 0, 0 },
852  { 102, sizeof((bens_rec).post), 0, 0, 0, 0, 0, 0, 0 },
853  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
854  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
855  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
856  { 102, sizeof((bens_rec).obstime), 0, 0, 0, 0, 0, 0, 0 },
857  { 100, 10, 0, 0, 0, 0, 0, 0, 0 },
858  { 100, 10, 0, 0, 0, 0, 0, 0, 0 },
859  { 100, 7, 0, 0, 0, 0, 0, 0, 0 },
860  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
861  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
862  { 100, 8, 0, 0, 0, 0, 0, 0, 0 },
863  { 100, 7, 0, 0, 0, 0, 0, 0, 0 },
864  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
865  { 100, 7, 0, 0, 0, 0, 0, 0, 0 },
866  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
867  { 100, 9, 0, 0, 0, 0, 0, 0, 0 },
868  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
869 #line 423 "candidate.ec"
870  };
871 #line 423 "candidate.ec"
872  _sqibind[0].sqldata = btn_rec.id;
873 #line 423 "candidate.ec"
874  _sqibind[1].sqldata = &t;
875 #line 423 "candidate.ec"
876  _sqobind[0].sqldata = (bens_rec).id;
877 #line 423 "candidate.ec"
878  _sqobind[1].sqldata = (bens_rec).pe1;
879 #line 423 "candidate.ec"
880  _sqobind[2].sqldata = (bens_rec).pe2;
881 #line 423 "candidate.ec"
882  _sqobind[3].sqldata = (bens_rec).dur;
883 #line 423 "candidate.ec"
884  _sqobind[4].sqldata = (bens_rec).t;
885 #line 423 "candidate.ec"
886  _sqobind[5].sqldata = (bens_rec).s;
887 #line 423 "candidate.ec"
888  _sqobind[6].sqldata = (bens_rec).e;
889 #line 423 "candidate.ec"
890  _sqobind[7].sqldata = (bens_rec).p;
891 #line 423 "candidate.ec"
892  _sqobind[8].sqldata = (bens_rec).type;
893 #line 423 "candidate.ec"
894  _sqobind[9].sqldata = (bens_rec).des;
895 #line 423 "candidate.ec"
896  _sqobind[10].sqldata = (bens_rec).det;
897 #line 423 "candidate.ec"
898  _sqobind[11].sqldata = (char *) &(bens_rec).post;
899 #line 423 "candidate.ec"
900  _sqobind[12].sqldata = (bens_rec).new_report;
901 #line 423 "candidate.ec"
902  _sqobind[13].sqldata = (bens_rec).active;
903 #line 423 "candidate.ec"
904  _sqobind[14].sqldata = (bens_rec).rfs;
905 #line 423 "candidate.ec"
906  _sqobind[15].sqldata = (char *) &(bens_rec).obstime;
907 #line 423 "candidate.ec"
908  _sqobind[16].sqldata = (bens_rec).prod;
909 #line 423 "candidate.ec"
910  _sqobind[17].sqldata = (bens_rec).prod2ary;
911 #line 423 "candidate.ec"
912  _sqobind[18].sqldata = (bens_rec).obsag;
913 #line 423 "candidate.ec"
914  _sqobind[19].sqldata = (bens_rec).obsloc;
915 #line 423 "candidate.ec"
916  _sqobind[20].sqldata = (bens_rec).prov_avail;
917 #line 423 "candidate.ec"
918  _sqobind[21].sqldata = (bens_rec).final_avail;
919 #line 423 "candidate.ec"
920  _sqobind[22].sqldata = (bens_rec).ownag;
921 #line 423 "candidate.ec"
922  _sqobind[23].sqldata = (bens_rec).ownloc;
923 #line 423 "candidate.ec"
924  _sqobind[24].sqldata = (bens_rec).maintag;
925 #line 423 "candidate.ec"
926  _sqobind[25].sqldata = (bens_rec).maintloc;
927 #line 423 "candidate.ec"
928  _sqobind[26].sqldata = (bens_rec).init;
929 #line 423 "candidate.ec"
930  _sqobind[27].sqldata = (bens_rec).dbsource;
931 #line 423 "candidate.ec"
932  _iqslct(&_SQ0, sqlcmdtxt, 2, _sqibind, 28, _sqobind, 0);
933 #line 423 "candidate.ec"
934  }
935 
936  }
937 
938  else if(l==3) {
939 
940 /*
941  * EXEC SQL select *
942  * into :bens_rec
943  * from sens
944  * where id=:btn_rec.id and
945  * pe1='P' and
946  * pe2='P' and
947  * dur='D' and
948  * t=:t and
949  * s='Z' and
950  * e='Z' and
951  * p='Z';
952  */
953 #line 429 "candidate.ec"
954  {
955 #line 429 "candidate.ec"
956  static const char *sqlcmdtxt[] =
957 #line 429 "candidate.ec"
958  {
959 #line 429 "candidate.ec"
960  " select * from sens where id = ? and pe1 = 'P' and pe2 = 'P' and dur = 'D' and t = ? and s = 'Z' and e = 'Z' and p = 'Z'",
961  0
962  };
963 #line 439 "candidate.ec"
964  static _SQCURSOR _SQ0 = {0};
965  static struct sqlvar_struct _sqibind[] =
966  {
967  { 100, 6, 0, 0, 0, 0, 0, 0, 0 },
968  { 108, 1, 0, 0, 0, 0, 0, 0, 0 },
969 #line 439 "candidate.ec"
970  };
971  static struct sqlvar_struct _sqobind[] =
972  {
973  { 100, 6, 0, 0, 0, 0, 0, 0, 0 },
974  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
975  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
976  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
977  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
978  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
979  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
980  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
981  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
982  { 100, 51, 0, 0, 0, 0, 0, 0, 0 },
983  { 100, 41, 0, 0, 0, 0, 0, 0, 0 },
984  { 102, sizeof((bens_rec).post), 0, 0, 0, 0, 0, 0, 0 },
985  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
986  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
987  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
988  { 102, sizeof((bens_rec).obstime), 0, 0, 0, 0, 0, 0, 0 },
989  { 100, 10, 0, 0, 0, 0, 0, 0, 0 },
990  { 100, 10, 0, 0, 0, 0, 0, 0, 0 },
991  { 100, 7, 0, 0, 0, 0, 0, 0, 0 },
992  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
993  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
994  { 100, 8, 0, 0, 0, 0, 0, 0, 0 },
995  { 100, 7, 0, 0, 0, 0, 0, 0, 0 },
996  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
997  { 100, 7, 0, 0, 0, 0, 0, 0, 0 },
998  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
999  { 100, 9, 0, 0, 0, 0, 0, 0, 0 },
1000  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
1001 #line 439 "candidate.ec"
1002  };
1003 #line 439 "candidate.ec"
1004  _sqibind[0].sqldata = btn_rec.id;
1005 #line 439 "candidate.ec"
1006  _sqibind[1].sqldata = &t;
1007 #line 439 "candidate.ec"
1008  _sqobind[0].sqldata = (bens_rec).id;
1009 #line 439 "candidate.ec"
1010  _sqobind[1].sqldata = (bens_rec).pe1;
1011 #line 439 "candidate.ec"
1012  _sqobind[2].sqldata = (bens_rec).pe2;
1013 #line 439 "candidate.ec"
1014  _sqobind[3].sqldata = (bens_rec).dur;
1015 #line 439 "candidate.ec"
1016  _sqobind[4].sqldata = (bens_rec).t;
1017 #line 439 "candidate.ec"
1018  _sqobind[5].sqldata = (bens_rec).s;
1019 #line 439 "candidate.ec"
1020  _sqobind[6].sqldata = (bens_rec).e;
1021 #line 439 "candidate.ec"
1022  _sqobind[7].sqldata = (bens_rec).p;
1023 #line 439 "candidate.ec"
1024  _sqobind[8].sqldata = (bens_rec).type;
1025 #line 439 "candidate.ec"
1026  _sqobind[9].sqldata = (bens_rec).des;
1027 #line 439 "candidate.ec"
1028  _sqobind[10].sqldata = (bens_rec).det;
1029 #line 439 "candidate.ec"
1030  _sqobind[11].sqldata = (char *) &(bens_rec).post;
1031 #line 439 "candidate.ec"
1032  _sqobind[12].sqldata = (bens_rec).new_report;
1033 #line 439 "candidate.ec"
1034  _sqobind[13].sqldata = (bens_rec).active;
1035 #line 439 "candidate.ec"
1036  _sqobind[14].sqldata = (bens_rec).rfs;
1037 #line 439 "candidate.ec"
1038  _sqobind[15].sqldata = (char *) &(bens_rec).obstime;
1039 #line 439 "candidate.ec"
1040  _sqobind[16].sqldata = (bens_rec).prod;
1041 #line 439 "candidate.ec"
1042  _sqobind[17].sqldata = (bens_rec).prod2ary;
1043 #line 439 "candidate.ec"
1044  _sqobind[18].sqldata = (bens_rec).obsag;
1045 #line 439 "candidate.ec"
1046  _sqobind[19].sqldata = (bens_rec).obsloc;
1047 #line 439 "candidate.ec"
1048  _sqobind[20].sqldata = (bens_rec).prov_avail;
1049 #line 439 "candidate.ec"
1050  _sqobind[21].sqldata = (bens_rec).final_avail;
1051 #line 439 "candidate.ec"
1052  _sqobind[22].sqldata = (bens_rec).ownag;
1053 #line 439 "candidate.ec"
1054  _sqobind[23].sqldata = (bens_rec).ownloc;
1055 #line 439 "candidate.ec"
1056  _sqobind[24].sqldata = (bens_rec).maintag;
1057 #line 439 "candidate.ec"
1058  _sqobind[25].sqldata = (bens_rec).maintloc;
1059 #line 439 "candidate.ec"
1060  _sqobind[26].sqldata = (bens_rec).init;
1061 #line 439 "candidate.ec"
1062  _sqobind[27].sqldata = (bens_rec).dbsource;
1063 #line 439 "candidate.ec"
1064  _iqslct(&_SQ0, sqlcmdtxt, 2, _sqibind, 28, _sqobind, 0);
1065 #line 439 "candidate.ec"
1066  }
1067 
1068  }
1069 
1070  else if(l==4) {
1071 
1072 /*
1073  * EXEC SQL select *
1074  * into :bens_rec
1075  * from sens
1076  * where id=:btn_rec.id and
1077  * pe1='P' and
1078  * pe2='P' and
1079  * dur='D' and
1080  * t=:t and
1081  * s='R' and
1082  * e='Z' and
1083  * p='Z';
1084  */
1085 #line 445 "candidate.ec"
1086  {
1087 #line 445 "candidate.ec"
1088  static const char *sqlcmdtxt[] =
1089 #line 445 "candidate.ec"
1090  {
1091 #line 445 "candidate.ec"
1092  " select * from sens where id = ? and pe1 = 'P' and pe2 = 'P' and dur = 'D' and t = ? and s = 'R' and e = 'Z' and p = 'Z'",
1093  0
1094  };
1095 #line 455 "candidate.ec"
1096  static _SQCURSOR _SQ0 = {0};
1097  static struct sqlvar_struct _sqibind[] =
1098  {
1099  { 100, 6, 0, 0, 0, 0, 0, 0, 0 },
1100  { 108, 1, 0, 0, 0, 0, 0, 0, 0 },
1101 #line 455 "candidate.ec"
1102  };
1103  static struct sqlvar_struct _sqobind[] =
1104  {
1105  { 100, 6, 0, 0, 0, 0, 0, 0, 0 },
1106  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1107  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1108  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1109  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1110  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1111  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1112  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1113  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1114  { 100, 51, 0, 0, 0, 0, 0, 0, 0 },
1115  { 100, 41, 0, 0, 0, 0, 0, 0, 0 },
1116  { 102, sizeof((bens_rec).post), 0, 0, 0, 0, 0, 0, 0 },
1117  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1118  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1119  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1120  { 102, sizeof((bens_rec).obstime), 0, 0, 0, 0, 0, 0, 0 },
1121  { 100, 10, 0, 0, 0, 0, 0, 0, 0 },
1122  { 100, 10, 0, 0, 0, 0, 0, 0, 0 },
1123  { 100, 7, 0, 0, 0, 0, 0, 0, 0 },
1124  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
1125  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1126  { 100, 8, 0, 0, 0, 0, 0, 0, 0 },
1127  { 100, 7, 0, 0, 0, 0, 0, 0, 0 },
1128  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
1129  { 100, 7, 0, 0, 0, 0, 0, 0, 0 },
1130  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
1131  { 100, 9, 0, 0, 0, 0, 0, 0, 0 },
1132  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
1133 #line 455 "candidate.ec"
1134  };
1135 #line 455 "candidate.ec"
1136  _sqibind[0].sqldata = btn_rec.id;
1137 #line 455 "candidate.ec"
1138  _sqibind[1].sqldata = &t;
1139 #line 455 "candidate.ec"
1140  _sqobind[0].sqldata = (bens_rec).id;
1141 #line 455 "candidate.ec"
1142  _sqobind[1].sqldata = (bens_rec).pe1;
1143 #line 455 "candidate.ec"
1144  _sqobind[2].sqldata = (bens_rec).pe2;
1145 #line 455 "candidate.ec"
1146  _sqobind[3].sqldata = (bens_rec).dur;
1147 #line 455 "candidate.ec"
1148  _sqobind[4].sqldata = (bens_rec).t;
1149 #line 455 "candidate.ec"
1150  _sqobind[5].sqldata = (bens_rec).s;
1151 #line 455 "candidate.ec"
1152  _sqobind[6].sqldata = (bens_rec).e;
1153 #line 455 "candidate.ec"
1154  _sqobind[7].sqldata = (bens_rec).p;
1155 #line 455 "candidate.ec"
1156  _sqobind[8].sqldata = (bens_rec).type;
1157 #line 455 "candidate.ec"
1158  _sqobind[9].sqldata = (bens_rec).des;
1159 #line 455 "candidate.ec"
1160  _sqobind[10].sqldata = (bens_rec).det;
1161 #line 455 "candidate.ec"
1162  _sqobind[11].sqldata = (char *) &(bens_rec).post;
1163 #line 455 "candidate.ec"
1164  _sqobind[12].sqldata = (bens_rec).new_report;
1165 #line 455 "candidate.ec"
1166  _sqobind[13].sqldata = (bens_rec).active;
1167 #line 455 "candidate.ec"
1168  _sqobind[14].sqldata = (bens_rec).rfs;
1169 #line 455 "candidate.ec"
1170  _sqobind[15].sqldata = (char *) &(bens_rec).obstime;
1171 #line 455 "candidate.ec"
1172  _sqobind[16].sqldata = (bens_rec).prod;
1173 #line 455 "candidate.ec"
1174  _sqobind[17].sqldata = (bens_rec).prod2ary;
1175 #line 455 "candidate.ec"
1176  _sqobind[18].sqldata = (bens_rec).obsag;
1177 #line 455 "candidate.ec"
1178  _sqobind[19].sqldata = (bens_rec).obsloc;
1179 #line 455 "candidate.ec"
1180  _sqobind[20].sqldata = (bens_rec).prov_avail;
1181 #line 455 "candidate.ec"
1182  _sqobind[21].sqldata = (bens_rec).final_avail;
1183 #line 455 "candidate.ec"
1184  _sqobind[22].sqldata = (bens_rec).ownag;
1185 #line 455 "candidate.ec"
1186  _sqobind[23].sqldata = (bens_rec).ownloc;
1187 #line 455 "candidate.ec"
1188  _sqobind[24].sqldata = (bens_rec).maintag;
1189 #line 455 "candidate.ec"
1190  _sqobind[25].sqldata = (bens_rec).maintloc;
1191 #line 455 "candidate.ec"
1192  _sqobind[26].sqldata = (bens_rec).init;
1193 #line 455 "candidate.ec"
1194  _sqobind[27].sqldata = (bens_rec).dbsource;
1195 #line 455 "candidate.ec"
1196  _iqslct(&_SQ0, sqlcmdtxt, 2, _sqibind, 28, _sqobind, 0);
1197 #line 455 "candidate.ec"
1198  }
1199 
1200  }
1201 
1202  if(sqlca.sqlcode < 0) {
1203 
1204  printf("database error\n %d",sqlca.sqlcode);
1205  exit(1);
1206 
1207  }
1208 
1209  if(sqlca.sqlcode == 100)
1210  continue;
1211 
1212  if(toupper(bens_rec.active[0])!='Y')
1213  continue;
1214 
1215  pc[0]=bens_rec.pe1[0];
1216  pc[1]=bens_rec.pe2[0];
1217  pc[2]=bens_rec.dur[0];
1218  pc[3]=bens_rec.t[0];
1219  pc[4]=bens_rec.s[0];
1220  pc[5]=bens_rec.e[0];
1221  pc[6]=bens_rec.p[0];
1222  pc[7]=0;
1223 
1224  strcpy(name,btn_rec.des);
1225 
1226  dtotal=pro_dly(btn_rec.id,pc,btim,etim,qual,dtn_values);
1227 
1228  if(dtotal==0 && bens_rec.rfs[0] =='0') {
1229 
1230 
1231  continue;
1232 
1233  }
1234 
1235 if(dtotal==0)
1236  printf("no data but rfs=y %s %s\n",btn_rec.id,pc);
1237 
1238  if(btn_rec.elev <= 0)
1239  printf("no elevation %s %d %d\n",btn_rec.id,btn_rec.elev,tip);
1240 
1241  ival=atoi(btn_rec.lat);
1242  len=strlen(btn_rec.lat);
1243 
1244  if(ival < 10000) {
1245 
1246  itemp=ival/100;
1247 
1248  itemp1=ival-itemp*100;
1249 
1250  flat=(float)itemp+(float)itemp1/60;
1251 
1252 
1253  }
1254 
1255  else if(ival > 10000) {
1256 
1257  itemp=ival/10000;
1258 
1259  itemp1=(ival-itemp*10000)/100;
1260 
1261  itemp2=ival-itemp*10000-itemp1*100;
1262 
1263  flat=(float)itemp+(float)itemp1/60 + (float)itemp2/3600;
1264 
1265 
1266 
1267  }
1268 
1269  else {
1270 
1271  printf("error\n");
1272 
1273  continue;
1274 
1275  }
1276 
1277 
1278  ival=atoi(btn_rec.lng);
1279  len=strlen(btn_rec.lng);
1280 
1281  if(ival < 100000) {
1282 
1283  itemp=ival/100;
1284 
1285  itemp1=ival-itemp*100;
1286 
1287  flng=(float)itemp+(float)itemp1/60;
1288 
1289 
1290  }
1291 
1292  else if(ival >=100000) {
1293 
1294  itemp=ival/10000;
1295 
1296  itemp1=(ival-itemp*10000)/100;
1297 
1298  itemp2=ival-itemp*10000-itemp1*100;
1299 
1300  flng=(float)itemp+(float)itemp1/60 + (float)itemp2/3600;
1301 
1302  }
1303 
1304  else {
1305 
1306  printf("error\n");
1307 
1308  continue;
1309 
1310  }
1311 
1312 
1313 
1314 
1315 
1316 
1317 tip=0;
1318 
1319 
1320  pc[0]=bens_rec.pe1[0];
1321  pc[1]=bens_rec.pe2[0];
1322  pc[2]=bens_rec.dur[0];
1323  pc[3]=bens_rec.t[0];
1324  pc[4]=bens_rec.s[0];
1325  pc[5]=bens_rec.e[0];
1326  pc[6]=bens_rec.p[0];
1327  pc[7]=0;
1328 
1329 
1330 if(bens_rec.s[0]=='Z') {
1331 
1332  pe2='P';
1333  dur='D';
1334 
1335  }
1336 
1337 else {
1338 
1339  pe2='C';
1340  dur='I';
1341 
1342  }
1343 
1344 /*
1345  * EXEC SQL select *
1346  * into :info
1347  * from gage_p
1348  * where id=:btn_rec.id and
1349  * pe1='P' and
1350  * pe2=:pe2 and
1351  * t='R' and
1352  * s=:bens_rec.s[0] and
1353  * e='Z' and
1354  * p='Z';
1355  */
1356 #line 601 "candidate.ec"
1357  {
1358 #line 601 "candidate.ec"
1359  static const char *sqlcmdtxt[] =
1360 #line 601 "candidate.ec"
1361  {
1362 #line 601 "candidate.ec"
1363  " select * from gage_p where id = ? and pe1 = 'P' and pe2 = ? and t = 'R' and s = ? and e = 'Z' and p = 'Z'",
1364  0
1365  };
1366 #line 610 "candidate.ec"
1367  static _SQCURSOR _SQ0 = {0};
1368  static struct sqlvar_struct _sqibind[] =
1369  {
1370  { 100, 6, 0, 0, 0, 0, 0, 0, 0 },
1371  { 108, 1, 0, 0, 0, 0, 0, 0, 0 },
1372  { 108, 1, 0, 0, 0, 0, 0, 0, 0 },
1373 #line 610 "candidate.ec"
1374  };
1375  static struct sqlvar_struct _sqobind[] =
1376  {
1377  { 100, 6, 0, 0, 0, 0, 0, 0, 0 },
1378  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1379  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1380  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1381  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1382  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1383  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1384  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1385  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1386 #line 610 "candidate.ec"
1387  };
1388 #line 610 "candidate.ec"
1389  _sqibind[0].sqldata = btn_rec.id;
1390 #line 610 "candidate.ec"
1391  _sqibind[1].sqldata = &pe2;
1392 #line 610 "candidate.ec"
1393  _sqibind[2].sqldata = &bens_rec.s[0];
1394 #line 610 "candidate.ec"
1395  _sqobind[0].sqldata = (info).id;
1396 #line 610 "candidate.ec"
1397  _sqobind[1].sqldata = (info).pe1;
1398 #line 610 "candidate.ec"
1399  _sqobind[2].sqldata = (info).pe2;
1400 #line 610 "candidate.ec"
1401  _sqobind[3].sqldata = (info).dur;
1402 #line 610 "candidate.ec"
1403  _sqobind[4].sqldata = (info).t;
1404 #line 610 "candidate.ec"
1405  _sqobind[5].sqldata = (info).s;
1406 #line 610 "candidate.ec"
1407  _sqobind[6].sqldata = (info).e;
1408 #line 610 "candidate.ec"
1409  _sqobind[7].sqldata = (info).p;
1410 #line 610 "candidate.ec"
1411  _sqobind[8].sqldata = (info).mode;
1412 #line 610 "candidate.ec"
1413  _iqslct(&_SQ0, sqlcmdtxt, 3, _sqibind, 9, _sqobind, 0);
1414 #line 610 "candidate.ec"
1415  }
1416 
1417  if(sqlca.sqlcode < 0) {
1418 
1419  printf("database error no gage_p\n",sqlca.sqlcode);
1420  tip=0;
1421  goto skip;
1422 
1423  }
1424 
1425 if(sqlca.sqlcode == 100) {
1426 
1427 /*
1428  * EXEC SQL select *
1429  * into :info
1430  * from gage_p
1431  * where id=:btn_rec.id and
1432  * pe1='P' and
1433  * pe2=:pe2 and
1434  * dur='Q' and
1435  * t='R' and
1436  * s=:bens_rec.s[0] and
1437  * e='Z' and
1438  * p='Z';
1439  */
1440 #line 622 "candidate.ec"
1441  {
1442 #line 622 "candidate.ec"
1443  static const char *sqlcmdtxt[] =
1444 #line 622 "candidate.ec"
1445  {
1446 #line 622 "candidate.ec"
1447  " select * from gage_p where id = ? and pe1 = 'P' and pe2 = ? and dur = 'Q' and t = 'R' and s = ? and e = 'Z' and p = 'Z'",
1448  0
1449  };
1450 #line 632 "candidate.ec"
1451  static _SQCURSOR _SQ0 = {0};
1452  static struct sqlvar_struct _sqibind[] =
1453  {
1454  { 100, 6, 0, 0, 0, 0, 0, 0, 0 },
1455  { 108, 1, 0, 0, 0, 0, 0, 0, 0 },
1456  { 108, 1, 0, 0, 0, 0, 0, 0, 0 },
1457 #line 632 "candidate.ec"
1458  };
1459  static struct sqlvar_struct _sqobind[] =
1460  {
1461  { 100, 6, 0, 0, 0, 0, 0, 0, 0 },
1462  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1463  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1464  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1465  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1466  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1467  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1468  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1469  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
1470 #line 632 "candidate.ec"
1471  };
1472 #line 632 "candidate.ec"
1473  _sqibind[0].sqldata = btn_rec.id;
1474 #line 632 "candidate.ec"
1475  _sqibind[1].sqldata = &pe2;
1476 #line 632 "candidate.ec"
1477  _sqibind[2].sqldata = &bens_rec.s[0];
1478 #line 632 "candidate.ec"
1479  _sqobind[0].sqldata = (info).id;
1480 #line 632 "candidate.ec"
1481  _sqobind[1].sqldata = (info).pe1;
1482 #line 632 "candidate.ec"
1483  _sqobind[2].sqldata = (info).pe2;
1484 #line 632 "candidate.ec"
1485  _sqobind[3].sqldata = (info).dur;
1486 #line 632 "candidate.ec"
1487  _sqobind[4].sqldata = (info).t;
1488 #line 632 "candidate.ec"
1489  _sqobind[5].sqldata = (info).s;
1490 #line 632 "candidate.ec"
1491  _sqobind[6].sqldata = (info).e;
1492 #line 632 "candidate.ec"
1493  _sqobind[7].sqldata = (info).p;
1494 #line 632 "candidate.ec"
1495  _sqobind[8].sqldata = (info).mode;
1496 #line 632 "candidate.ec"
1497  _iqslct(&_SQ0, sqlcmdtxt, 3, _sqibind, 9, _sqobind, 0);
1498 #line 632 "candidate.ec"
1499  }
1500 
1501  if(sqlca.sqlcode < 0) {
1502 
1503  printf("database error\n %d",sqlca.sqlcode);
1504  exit(1);
1505 
1506  }
1507 
1508 }
1509 
1510 if(sqlca.sqlcode == 100) {
1511 
1512  if(pc[4]!='R')
1513  printf("no gage_p entry %s %s\n",btn_rec.id,pc);
1514  tip=0;
1515 
1516  }
1517 
1518 else if(info.mode[0]=='W' || info.mode[0]=='S')
1519  tip=1;
1520 
1521 
1522  if(tip==0 && btn_rec.elev <= 0)
1523  continue;
1524 
1525 
1526  if(flat >= 37 && btn_rec.elev >= 7000 && tip==0) {
1527 
1528  printf("tipping bucket reject %s %d\n",
1530 
1531  continue;
1532 
1533  }
1534 
1535  else if(flat >= 39 && btn_rec.elev >= 6000 && tip==0) {
1536 
1537  printf("tipping bucket reject 2 %s %d\n",
1539 
1540  continue;
1541 
1542  }
1543 
1544  else if(flat >= 41 && btn_rec.elev >= 5000 && tip==0) {
1545 
1546  printf("tipping bucket reject 2 %s %d\n",
1548 
1549  continue;
1550 
1551  }
1552 
1553  else if(flat >= 43 && btn_rec.elev >= 4000 && tip==0) {
1554 
1555  printf("tipping bucket reject 2 %s %d\n",
1557 
1558  continue;
1559 
1560  }
1561 
1562 skip:
1563  for(ii=0;ii<49;ii++) {
1564 
1565  if(btn_rec.des[ii]== ' ' &&
1566  btn_rec.des[ii+1]==' ') {
1567 
1568  btn_rec.des[ii]=0;
1569  break;
1570 
1571  }
1572 
1573  }
1574 
1575  fprintf(fp,"%s %s %f %f %d %d %s\n",
1576  btn_rec.id,pc,flat,flng,btn_rec.elev,tip,btn_rec.des);
1577 
1578 
1579  }
1580 
1581 
1582 }
1583 
1584 
1585 }
struct data_rec data_record
long SQLCODE
char pe2
Definition: candidate.c:99
static const char * _Cn1
Definition: candidate.c:8
int mday[]
Definition: candidate.c:329
char s
Definition: candidate.c:99
void main(int argc, char **argv)
Definition: candidate.c:330
static _SQCURSOR * _SQ1
Definition: candidate.c:8
struct eens_rec bens_rec
char pe1
Definition: candidate.c:99
struct pro_dly_rec dly_rec
struct sqlca_s sqlca
struct pro_hrly_rec hrly_rec
_SQCURSOR * _iqnprep()
char dur
Definition: candidate.c:99
struct gage_info info
char t
Definition: candidate.c:99
struct etn_rec btn_rec
int maxdays
Definition: daily_qc.c:85
time_t btim
Definition: daily_qc.c:140
time_t tim
Definition: daily_qc.c:154
char type[5]
Definition: daily_qc.c:98
int hour
Definition: display_data.c:30
char qual[10]
Definition: display_data.c:29
int day
Definition: display_data.c:30
struct stim etim
Definition: display_data.c:21
int year
Definition: display_data.c:30
int month
Definition: display_data.c:30
void init_candidate()
Definition: init_candidate.c:9
printf("pcp %d\n", pcp_in_use[103])
exit(1)
int pro_dly(char *hb5, char *parm, struct stim begin_date, struct stim end_date, char *qual, struct stn_values *stn_values)
Definition: pro_dly.c:208
int rfs(int)
Definition: can.c:329
int idote
Definition: can.c:346
int cztime
Definition: can.c:342
char source[9]
Definition: can.c:331
char pe2
Definition: can.c:333
char t
Definition: can.c:335
char s
Definition: can.c:336
int irev
Definition: can.c:347
char p
Definition: can.c:338
double values[96]
Definition: can.c:349
char lwal
Definition: can.c:345
int zdate
Definition: can.c:339
char lwals[96]
Definition: can.c:350
int idur
Definition: can.c:343
int ztime
Definition: can.c:340
char pedtsep[8]
Definition: can.c:351
double codp
Definition: can.c:344
char dur
Definition: can.c:334
char pe1
Definition: can.c:332
double value
Definition: can.c:348
char e
Definition: can.c:337
int czdate
Definition: can.c:341
Definition: can.c:293
char dbsource[4]
Definition: can.c:321
char maintag[7]
Definition: can.c:318
char maintloc[4]
Definition: can.c:319
char obsag[7]
Definition: can.c:312
char pe1[2]
Definition: can.c:295
char e[2]
Definition: can.c:300
char det[41]
Definition: can.c:304
char active[2]
Definition: can.c:307
char p[2]
Definition: can.c:301
char init[9]
Definition: can.c:320
char pe2[2]
Definition: can.c:296
char des[51]
Definition: can.c:303
char prod[10]
Definition: can.c:310
char prov_avail[2]
Definition: can.c:314
char prod2ary[10]
Definition: can.c:311
char rfs[2]
Definition: can.c:308
char type[2]
Definition: can.c:302
char obsloc[4]
Definition: can.c:313
char t[2]
Definition: can.c:298
char dur[2]
Definition: can.c:297
char new_report[2]
Definition: can.c:306
char s[2]
Definition: can.c:299
char ownag[7]
Definition: can.c:316
char final_avail[8]
Definition: can.c:315
int obstime
Definition: can.c:309
char ownloc[4]
Definition: can.c:317
int post
Definition: can.c:305
char det[41]
Definition: build_list.c:129
char huc[9]
Definition: build_list.c:135
char init[9]
Definition: build_list.c:130
int elev
Definition: build_list.c:133
char plat[9]
Definition: build_list.c:127
char des[51]
Definition: build_list.c:128
char id[6]
Definition: build_list.c:126
char lng[8]
Definition: build_list.c:132
char cwa[4]
Definition: build_list.c:139
char dbsource[4]
Definition: build_list.c:141
char lat[7]
Definition: build_list.c:131
char cou[4]
Definition: build_list.c:136
char zon[5]
Definition: build_list.c:137
int post
Definition: build_list.c:140
char hsa[4]
Definition: build_list.c:138
char stat[3]
Definition: build_list.c:134
Definition: can.c:144
char pe2[2]
Definition: can.c:147
char dur[2]
Definition: can.c:148
char p[2]
Definition: can.c:152
char s[2]
Definition: can.c:150
char pe1[2]
Definition: can.c:146
char t[2]
Definition: can.c:149
char mode[2]
Definition: can.c:153
char e[2]
Definition: can.c:151
char qzday06[2]
Definition: can.c:265
double zday10
Definition: can.c:238
double zday04
Definition: can.c:232
char qzday19[2]
Definition: can.c:278
char qzday17[2]
Definition: can.c:276
double zday17
Definition: can.c:245
char qzday29[2]
Definition: can.c:288
double zday11
Definition: can.c:239
double zday08
Definition: can.c:236
double zday28
Definition: can.c:256
char qzday01[2]
Definition: can.c:260
char e[2]
Definition: can.c:225
double zday26
Definition: can.c:254
char pe2[2]
Definition: can.c:221
char qzday13[2]
Definition: can.c:272
char t[2]
Definition: can.c:223
double zday18
Definition: can.c:246
char qzday04[2]
Definition: can.c:263
int cal_yr
Definition: can.c:227
double zday15
Definition: can.c:243
char qzday05[2]
Definition: can.c:264
char qzday16[2]
Definition: can.c:275
char qzday26[2]
Definition: can.c:285
double zday22
Definition: can.c:250
double zday31
Definition: can.c:259
double zday09
Definition: can.c:237
char qzday30[2]
Definition: can.c:289
char qzday28[2]
Definition: can.c:287
char qzday08[2]
Definition: can.c:267
char qzday25[2]
Definition: can.c:284
double zday30
Definition: can.c:258
double zday05
Definition: can.c:233
double zday14
Definition: can.c:242
double zday01
Definition: can.c:229
char pe1[2]
Definition: can.c:220
double zday23
Definition: can.c:251
double zday20
Definition: can.c:248
double zday27
Definition: can.c:255
double zday07
Definition: can.c:235
char qzday14[2]
Definition: can.c:273
char qzday15[2]
Definition: can.c:274
double zday06
Definition: can.c:234
char qzday09[2]
Definition: can.c:268
char qzday21[2]
Definition: can.c:280
double zday19
Definition: can.c:247
char qzday23[2]
Definition: can.c:282
char qzday31[2]
Definition: can.c:290
char qzday27[2]
Definition: can.c:286
char qzday07[2]
Definition: can.c:266
double zday02
Definition: can.c:230
char p[2]
Definition: can.c:226
double zday24
Definition: can.c:252
char qzday22[2]
Definition: can.c:281
double zday12
Definition: can.c:240
double zday13
Definition: can.c:241
char qzday12[2]
Definition: can.c:271
double zday03
Definition: can.c:231
char s[2]
Definition: can.c:224
double zday21
Definition: can.c:249
char qzday24[2]
Definition: can.c:283
double zday16
Definition: can.c:244
int mon
Definition: can.c:228
char qzday20[2]
Definition: can.c:279
double zday29
Definition: can.c:257
double zday25
Definition: can.c:253
char qzday02[2]
Definition: can.c:261
char dur[2]
Definition: can.c:222
char qzday18[2]
Definition: can.c:277
char qzday10[2]
Definition: can.c:269
char qzday03[2]
Definition: can.c:262
char qzday11[2]
Definition: can.c:270
char qzhr05[2]
Definition: can.c:197
double zhr02
Definition: can.c:170
char qzhr14[2]
Definition: can.c:206
double zhr01
Definition: can.c:169
double zhr16
Definition: can.c:184
double zhr21
Definition: can.c:189
char qzhr11[2]
Definition: can.c:203
double zhr15
Definition: can.c:183
char qzhr21[2]
Definition: can.c:213
char dur[2]
Definition: can.c:160
char qzhr10[2]
Definition: can.c:202
char p[2]
Definition: can.c:164
double zhr22
Definition: can.c:190
char qzhr01[2]
Definition: can.c:193
char qzhr20[2]
Definition: can.c:212
char qzhr02[2]
Definition: can.c:194
int mon
Definition: can.c:166
double zhr05
Definition: can.c:173
double zhr11
Definition: can.c:179
char qzhr12[2]
Definition: can.c:204
double zhr00
Definition: can.c:168
double zhr23
Definition: can.c:191
double zhr12
Definition: can.c:180
char qzhr23[2]
Definition: can.c:215
char qzhr00[2]
Definition: can.c:192
double zhr03
Definition: can.c:171
double zhr17
Definition: can.c:185
char pe1[2]
Definition: can.c:158
char qzhr08[2]
Definition: can.c:200
double zhr14
Definition: can.c:182
double zhr06
Definition: can.c:174
double zhr10
Definition: can.c:178
char qzhr13[2]
Definition: can.c:205
char qzhr15[2]
Definition: can.c:207
double zhr13
Definition: can.c:181
char qzhr17[2]
Definition: can.c:209
char qzhr16[2]
Definition: can.c:208
int zday
Definition: can.c:167
char s[2]
Definition: can.c:162
char t[2]
Definition: can.c:161
int cal_yr
Definition: can.c:165
char qzhr03[2]
Definition: can.c:195
double zhr20
Definition: can.c:188
char qzhr06[2]
Definition: can.c:198
double zhr08
Definition: can.c:176
double zhr19
Definition: can.c:187
char pe2[2]
Definition: can.c:159
double zhr18
Definition: can.c:186
char qzhr18[2]
Definition: can.c:210
double zhr04
Definition: can.c:172
char qzhr19[2]
Definition: can.c:211
double zhr09
Definition: can.c:177
char qzhr04[2]
Definition: can.c:196
char qzhr09[2]
Definition: can.c:201
char e[2]
Definition: can.c:163
char qzhr22[2]
Definition: can.c:214
double zhr07
Definition: can.c:175
char qzhr07[2]
Definition: can.c:199
long sqlerrd[6]
Definition: build_list.c:50
long sqlcode
Definition: build_list.c:47
struct sqlca_s::sqlcaw_s sqlwarn
char sqlerrm[72]
Definition: build_list.c:48
char sqlerrp[8]
Definition: build_list.c:49
Definition: misc.h:55
int minute
Definition: misc.h:61
int day
Definition: misc.h:59
int year
Definition: misc.h:57
int hour
Definition: misc.h:60
int month
Definition: misc.h:58