ALTER TRIGGER "tib_pa_erisood" before insert order 1 on
DBA.pa_erisood
referencing new as new_name
for each row
begin
  declare id1 integer;
  if(new_name."id" is null) or(new_name."id" = 0) then
    select getid_pa_erisood(new_name.a_aasta) into id1 from DUMMY;
    set new_name."id"=id1
  end if;
  if new_name.v_aasta>2020 then
    call pr_kanne_add(new_name.v_akuu,new_name.v_aasta,get_skoop(5,new_name.yksusnr),5);
  end if;
  set new_name.kell=Now(*)
end