set heading off
set pagesize 0
set linesize 200
set trimspool on
set feedback off
set verify off
set echo off
set termout off
set time off
set timing off
alter session set nls_territory='italy';
UPDATE MNP_DBP2DBCFX D
SET D.FLAG_LAVORATO=2 --in lavorazione
WHERE D.FLAG_LAVORATO=0
AND   D.DATA_CUT_OVER BETWEEN TO_DATE('&1','DDMMYYYY') AND TO_DATE('&2','DDMMYYYY') 
AND   ROWNUM < &3;
spool mnp_dbp2FASTWEB.csv
SELECT ID_RICHIESTA
||';'||MSISDN
||';'||CODICE_OPERATORE_RECIPIENT
||';'||NVL(ROUTING_NUMBER,' ') 
||';'||TO_CHAR(DATA_CUT_OVER,'ddmmyyyy hh24miss')
||';'||TO_CHAR(SYSDATE,'ddmmyyyy hh24miss')
||';'
FROM MNP_DBP2DBCFX D
WHERE D.FLAG_LAVORATO=2;
spool off
UPDATE MNP_DBP2DBCFX D
SET D.FLAG_LAVORATO=1
WHERE  D.FLAG_LAVORATO=2;
COMMIT;
/
EXIT