ALTER TABLE PARAMPEDIDO DROP CONSTRAINT CKC_IDPENDFINANLANC
/

ALTER TABLE PARAMPEDIDO MODIFY IDPENDFINANLANC DEFAULT '1'
/

BEGIN
   FOR C_PARAM IN (SELECT CDFILIAL, NVL(IDPENDFINANLANC, 'N') IDPENDFINANLANC, IDPENDFINAN
                     FROM PARAMPEDIDO)
   LOOP
      IF C_PARAM.IDPENDFINANLANC = 'N' THEN
         UPDATE PARAMPEDIDO
            SET IDPENDFINANLANC = '1'
          WHERE CDFILIAL = C_PARAM.CDFILIAL;
      ELSE
         IF C_PARAM.IDPENDFINANLANC = 'S' THEN
            UPDATE PARAMPEDIDO
               SET IDPENDFINANLANC = C_PARAM.IDPENDFINAN
             WHERE CDFILIAL = C_PARAM.CDFILIAL;
         END IF;
      END IF;
   END LOOP;
END;
/

ALTER TABLE PARAMPEDIDO ADD CONSTRAINT CKC_IDPENDFINANLANC CHECK (IDPENDFINANLANC in ('1','2','3'))
/ 