CREATE TRIGGER "tib_pa_leping_tun" BEFORE INSERT
ORDER 1 ON "DBA"."pa_leping_tun"
REFERENCING NEW AS new_name
FOR EACH ROW
BEGIN
  declare id1 integer;
  if(new_name.leptunnr is null) or(new_name.leptunnr = 0) then
    select getid_pa_leping_tun(*) into id1 from DUMMY;
    set new_name.leptunnr=id1
  end if
END