--ABS-141099
ALTER TABLE DATE_YEARWEEKDAY ADD (WEEKSEQ NUMBER NULL);
CREATE INDEX XAK3DATE_YEARWEEKDAY ON DATE_YEARWEEKDAY (WEEKSEQ);

create or replace procedure fill_weekseq is
  lv_prevweek number := 0;
  lv_teller   number := -1;
begin
  for x in (select dyw.week, dyw.date_ from date_yearweekday dyw order by dyw.date_ asc) loop
    begin
      if lv_prevweek <> x.week then
        begin
          lv_teller   := lv_teller + 1;
          lv_prevweek := x.week;
        end;
      end if;
      update date_yearweekday y set y.weekseq = lv_teller where y.date_ = x.date_;
    end;
  end loop; --x
  commit;
end fill_weekseq;
/

execute fill_weekseq;

drop procedure fill_weekseq;
