CREATE TABLE USR_FORNECEDOR   AS (SELECT * FROM FORNECEDOR)
/
CREATE TABLE USR_PRAZOPGTFORN AS (SELECT * FROM PRAZOPGTFORN)
/

INSERT INTO PRAZOPGTFORN(CDFORNECED, NRDIASPGTOFO, VRPERCPGTOFO)
SELECT
 SUBSTR(CDFORNECED,2,21),
 NRDIASPGTOFO,
 VRPERCPGTOFO
FROM
 PRAZOPGTFORN
WHERE
 SUBSTR(CDFORNECED, 1,2)= 'JJ' AND
 NOT EXISTS
  (SELECT CDFORNECED
   FROM PRAZOPGTFORN B
   WHERE B.CDFORNECED = SUBSTR(PRAZOPGTFORN.CDFORNECED, 2,21))
/
DELETE FORNECEDOR WHERE SUBSTR(CDFORNECED, 1,2) = 'JJ'
/
INSERT INTO PRAZOPGTFORN(CDFORNECED, NRDIASPGTOFO, VRPERCPGTOFO)
SELECT
 SUBSTR(CDFORNECED,2,21),
 NRDIASPGTOFO,
 VRPERCPGTOFO
FROM
 PRAZOPGTFORN
WHERE
 SUBSTR(CDFORNECED, 1,2)= 'FF' AND
 NOT EXISTS
  (SELECT CDFORNECED
   FROM PRAZOPGTFORN B
   WHERE B.CDFORNECED = SUBSTR(PRAZOPGTFORN.CDFORNECED, 2,21))
/
DELETE FORNECEDOR WHERE SUBSTR(CDFORNECED, 1,2) = 'FF'
/