ALTER FUNCTION "DBA"."existid_objlist"( in a_klass char(16), in a_nimi char(100) default 'Uus projekt' ) 
returns integer
begin
  declare ll_objectnr integer;
  set a_klass = "left"(a_klass+space(16),16);
  select first objlist.objectnr into ll_objectnr from objlist where objlist.object = a_klass order by objlist.kell desc;
  if ll_objectnr = 0 or ll_objectnr is null then
    insert into objlist( object,nimi ) values( a_klass, a_nimi ) ;
    select objlist.objectnr into ll_objectnr from objlist where objlist.object = a_klass
  end if;
  return(ll_objectnr)
end