UPDATE CANDIDACY_PERIOD SET CANDIDACY_PERIOD.KEY_EXECUTION_INTERVAL = (SELECT ID_INTERNAL FROM EXECUTION_INTERVAL WHERE EXECUTION_INTERVAL.STATE = 'C' AND EXECUTION_INTERVAL.OJB_CONCRETE_CLASS = 'net.sourceforge.fenixedu.domain.ExecutionYear');