CREATE FUNCTION "dba"."existid_kp_obj_marve"( in a_marve char(30), in a_skoop integer default 0 )
RETURNS INTEGER
BEGIN
  DECLARE ll_return INTEGER;
  SELECT FIRST "kp_obj"."objnr" INTO ll_return FROM "kp_obj" WHERE ("kp_obj"."skoop"=a_skoop or a_skoop=0) and Trim("kp_obj"."marve")=a_marve order by objnr;
  if ll_return is null then
    set ll_return=0
  end if;
  RETURN ll_return;
END