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