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_DBP2COOP D
SET D.FLAG_LAVORATO=2 --in lavorazione
WHERE D.FLAG_LAVORATO=0
and D.MSISDN in (
    select MSISDN from (
                           SELECT C.MSISDN
                                , ROW_NUMBER() OVER (ORDER BY C.MSISDN) rno
                           FROM MNP_DBP2COOP C where C.FLAG_LAVORATO = 0)
    WHERE rno <= &1);
--spool tmp_mnp_dbp2COOP.txt append; da usare se fare append
spool &2/tmp_mnp_dbp2COOP.txt;
SELECT 'telephone-number='''
||MSISDN
||''' result-info {routing-number='''||ROUTING_NUMBER
||'''};'
FROM MNP_DBP2COOP D
WHERE D.FLAG_LAVORATO=2 ORDER BY MSISDN;
spool off
/
EXIT