ALTER TABLE HISTLOGCANCNOTA DROP CONSTRAINT PK_HISTLOGCANCNOTA
/

DROP INDEX PK_HISTLOGCANCNOTA
/

DECLARE
   V_COUNT NUMBER;
BEGIN
   SELECT COUNT(1)
     INTO V_COUNT
     FROM HISTLOGCANCNOTA
    WHERE DTHRCANCNF IS NULL;
    
   IF V_COUNT > 0 THEN
      UPDATE HISTLOGCANCNOTA
         SET DTHRCANCNF = TO_DATE('01/01/1889')
       WHERE DTHRCANCNF IS NULL;
   END IF;
END;
/

ALTER TABLE HISTLOGCANCNOTA ADD CONSTRAINT PK_HISTLOGCANCNOTA PRIMARY KEY (CDFILIALNFCANC, NRLANCNFCANC, NRSEQITPROCANC, DTHRCANCNF)
/