Torna al Thread
CREATE OR REPLACE PROCEDURE AggiornaABI_CAB AS
CURSOR TabCAB IS SELECT COD_ABI, COD_CAB, INDIRIZZO, NUMCIV, BANCA, FILIALE FROM ZCNTB_EXTRA_ABICAB;
strCOD_ABI VARCHAR2(100);
strCOD_CAB VARCHAR2(100);
strINDIRIZZO VARCHAR2(100);
strNUMCIV VARCHAR2(100);
strBANCA VARCHAR2(100);
strFILIALE VARCHAR2(100);
RowTabCAB TabCAB%ROWTYPE;
BEGIN
DELETE FROM ZCTR_ABI;
INSERT INTO ZCTR_ABI SELECT DISTINCT(COD_ABI), BANCA FROM ZCNTB_EXTRA_ABICAB;
DELETE FROM ZCTR_CAB;
OPEN TabCAB;
LOOP
FETCH TabCAB INTO RowTabCAB;
EXIT WHEN TabCAB%NOTFOUND;
INSERT INTO ZCTR_CAB(COD_ABI, COD_CAB, INDIRIZZO, NR_CIVICO, DESC_AGENZIA) VALUES(strCOD_ABI, strCOD_CAB, strINDIRIZZO, strNUMCIV, strBANCA || ' - ' || strFILIALE);
END LOOP;
CLOSE TabCAB;
COMMIT;
EXCEPTION
WHEN too_many_rows THEN
dbms_output.put_line('*** Exc: too many rows');
WHEN no_data_found THEN
dbms_output.put_line('*** Exc: no data');
END AggiornaABI_CAB;
/