ALTER TRIGGER "tib_pv_kanne" before insert order 1 on
DBA.pv_kanne
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_pv_kanne(*) into id1 from DUMMY;
    set new_name.id=id1
  end if;
  if new_name.ytk is null then
    set new_name.ytk=0
  end if;
  if years(new_name.kuup)>2020 then
    call pr_kanne_add(month(new_name.kuup),years(new_name.kuup),new_name.yksusnr,6);
  end if;
  set new_name.kell=Now(*)
end