CREATE FUNCTION "DBA"."get_eak_totalsum"( in a_id_dk_earve integer, in a_id_dk_earve_sum integer default 1 )
RETURNS decimal(20,2)
BEGIN
  declare ldc_return decimal(20,2);
  select totalsum into ldc_return from "dk_earve_sum" where "dk_earve_sum"."id_dk_earve"=a_id_dk_earve and "dk_earve_sum"."id"=a_id_dk_earve_sum;
  if ldc_return is null then
    set ldc_return=0
  end if;
  return ldc_return;
END