CREATE TRIGGER "tdb_pa_plnr" BEFORE DELETE
ORDER 1 ON "DBA"."pa_plnr"
REFERENCING OLD AS old_name
FOR EACH ROW
BEGIN
  if old_name.v_aasta>2020 then
    call pr_kanne_add(old_name.v_akuu,old_name.v_aasta,old_name.skoop,5);
  end if;
  if old_name.t_aasta>2020 and old_name.t_akuu<>old_name.v_akuu then
    call pr_kanne_add(old_name.t_akuu,old_name.t_aasta,old_name.skoop,5);
  end if;
END