Postgres 默认函数的函数别名

Tom*_*mmy 7 postgresql

当结果为空时,我总是使用 NVL() 来分配默认值。

但是在 PostgreSql 中只有 COALESCE()。

我可以给 COALESCE 函数一个别名以便它与 NVL 一起执行吗?

或者我可以以某种方式复制函数声明吗?

kli*_*lin 5

您可以使用此包装器:

create or replace function nvl (anyelement, anyelement)
returns anyelement language sql as $$
    select coalesce($1, $2)
$$;
Run Code Online (Sandbox Code Playgroud)

另请参阅NVL 和 Coalesce 之间的 Oracle 差异