7

I always use NVL() for assigning a default value when the result is null.

However in PostgreSql there is only COALESCE().

Can I give the COALESCE function an alias so it executes with NVL?

Or can I copy the function declaration somehow?

Tommy
  • 576
  • 6
  • 30

1 Answers1

5

You can use this wrapper:

create or replace function nvl (anyelement, anyelement)
returns anyelement language sql as $$
    select coalesce($1, $2)
$$;

See also Oracle Differences between NVL and Coalesce.

Community
  • 1
  • 1
klin
  • 99,138
  • 12
  • 177
  • 203