Hi,
In relase 3.6.0, these two oracle.nvl functions are released.
CREATE OR REPLACE FUNCTION oracle.nvl(bigint, int)
RETURNS bigint AS $$
SELECT coalesce($1, $2)
$$ LANGUAGE sql IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION oracle.nvl(numeric, int)
RETURNS numeric AS $$
SELECT coalesce($1, $2)
$$ LANGUAGE sql IMMUTABLE STRICT;
I expect these functions to work like Oracle's nvl.
However, these functions works as follows.
postgres=# select oracle.nvl(null::bigint, 0);
nvl
-----
(1 row)
postgres=# select oracle.nvl(null::numeric, 0);
nvl
-----
(1 row)
I think the problem is that these functions are defined as STRICT functions.
According to the PostgreSQL Documentation, STRICT indicates that the function always returns null whenever any of its arguments are null.
I think the solution is to remove STRICT.
Regards,
Ryohei Takahashi