DECLARE
  V_SQL VARCHAR2(500);
BEGIN
  BEGIN
    EXECUTE IMMEDIATE 'DROP SEQUENCE SEQ_LOGDOWNLOADAF';
  EXCEPTION
    WHEN OTHERS THEN
      NULL;
  END;
  SELECT  'CREATE SEQUENCE SEQ_LOGDOWNLOADAF MINVALUE 0 START WITH '|| ((NVL(MAX(NRSEQDOWNLOADAF), 0))+1) ||' INCREMENT BY 1 CACHE 20'
    INTO V_SQL
  FROM LOGDOWNLOADAF;
  EXECUTE IMMEDIATE V_SQL;
END;
/