Forum OpenACS Development: Re: I could not able to execute nvl function from PostgreSql

...or you could define one in pl/pgsql itself, probably like this (but you may need to overload it for several data types):
-- Oracle NVL for varchars
create or replace function nvl(varchar,varchar) returns varchar as '
  declare
    p_expr1 alias for $1;
    p_expr2 alias for $2;
    v_result varchar;
  begin
    -- sanity checks
    if p_expr2 is null then
       raise exception ''Value for expr2 cannot be NULL!'';
       return '''';
    else
      select coalesce (p_expr1, p_expr2)
      into v_result;
    end if;
    return v_result;
  end;
' language 'plpgsql';