CREATE FUNCTION "DBA"."get_otsek_service_id"( in a_serviceid char(30))
RETURNS INTEGER
begin
  declare li_servicenr integer;
  set a_serviceid=Trim(a_serviceid);
  if Length(a_serviceid)>0 then
    select first servicenr into li_servicenr from otsek_service where serviceid=a_serviceid
  end if;
  if li_servicenr=0 then
    set li_servicenr=null
  end if;
  return li_servicenr;
end