--L'indicatore riporta giornalmente il numero totale di richieste Recipient --di tipo Consumer che sono state accodate nei giorni precedenti alla data di sistema --e che risultano ancora accodate su DBC. --I dati devono essere aggregati per: --Causale Accodamento. --Sono prodotti tanti record riportanti ognuno il totale per quante sono --i possibili valori di Causale Accodamento. --Il record è prodotto anche nel caso il valore rilevato sia "zero". SET serveroutput on declare i integer; var_causale_accodamento varchar2(100); valore varchar2(255); data_val date; file1 UTL_FILE.file_type; freq varchar2(255):='&1'; begin dbms_output.put_line('apro il file ' || 'MNP' || '.' || to_char(sysdate,'yyyyMMdd')); file1 := UTL_FILE.fopen('&2','MNP' || '.' || to_char(sysdate,'yyyyMMdd'),'a'); for i in 1..4 loop if i=1 then var_causale_accodamento:='DATA CUT OVER RICHIESTA DAL CLIENTE > DATA CUT OVER CALCOLATA'; end if; if i=2 then var_causale_accodamento:='SCARTATA PER WAITING LIST'; end if; if i=3 then var_causale_accodamento:='IN OVERFLOW'; end if; if i=4 then var_causale_accodamento:='SOSPESA PER MANUTENZIONE PROGRAMMATA'; end if; select count(*),sysdate into valore, data_val from mnp_gestione_richiesta_rec a, mnp_storico_richiesta_rec b where a.id_richiesta = b.id_richiesta and a.stato=3 and b.data_lavorazione <= trunc(sysdate)-1/86400 and b.stato_a = 3 and a.tipo_cliente = 'BU' and UPPER(a.causale_accodamento)=var_causale_accodamento; UTL_FILE.put_line(file1,'SRBUACQ3A'||';'||var_causale_accodamento||';'||valore||';' ||freq||';'||'&3'|| ';' ||to_char(data_val,'yyyymmdd')||';'||to_char(data_val,'hh24:mi:ss') ||';' ||to_char(sysdate,'yyyymmdd')||';'||to_char(sysdate,'hh24:mi:ss') ||';' ||'0'||';'||var_causale_accodamento||';;'); end loop; UTL_FILE.fflush(file1); UTL_FILE.fclose(file1); dbms_output.put_line('chiudo il file ' || 'MNP' || '.' || to_char(sysdate,'yyyyMMdd')); exception when others then DBMS_OUTPUT.PUT_LINE(sqlerrm); end; / exit