Postgres默认功能的功能别名 [英] Function alias for Postgres default function

查看:99
本文介绍了Postgres默认功能的功能别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

但是在PostgreSql中只有COALESCE()。

However in PostgreSql there is only COALESCE().

我可以给COALESCE函数一个别名以便使用NVL执行吗?

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

还是可以以某种方式复制函数声明? p>

Or can I copy the function declaration somehow?

推荐答案

您可以使用此包装器:

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

另请参见

See also Oracle Differences between NVL and Coalesce.

这篇关于Postgres默认功能的功能别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆