CREATE TRIGGER "tib_pl_koolit" BEFORE INSERT
ORDER 1 ON "DBA"."pl_koolit"
referencing new as new_name
for each row
begin
  declare id1 integer;
  if(new_name.koolitnr is null) or(new_name.koolitnr = 0) then
    select getid_pl_koolit() into id1 from DUMMY;
    set new_name.koolitnr=id1
  end if;
  set new_name.kell=Now(*)
end