CREATE TRIGGER "tib_pa_kaader_pens" BEFORE INSERT
ORDER 1 ON "dba"."pa_kaader_pens"
REFERENCING NEW AS new_name
FOR EACH ROW
BEGIN
  declare id1 integer;
  if(new_name.asutpensnr is null) or(new_name.asutpensnr = 0) then
    select getid_pa_kaader_pens(*) into id1 from DUMMY;
    set new_name.asutpensnr=id1
  end if;
  set new_name.kuup1=get_peralg(new_name.kuup1)
END