create or replace procedure update_chk_material(sheetids in chk_materialcheck.sheetid%type) is
  flag1 chk_materialcheck.auditflag%type;
  flag2 chk_materialcheck.auditflag2%type;
  cursor yb(sheetids chk_materialcheck.sheetid%type) is select auditflag,auditflag2 from chk_materialcheck where sheetid=sheetids;
begin
      open yb(sheetids);
      loop
          fetch yb into flag1,flag2;
          exit when yb%notfound;
          if (flag1='Y') and (flag2='Y') then
             update chk_materialcheck set passed='Y' where sheetid=sheetids;
          end if;
      end loop;
      close yb;
end update_chk_material;