3、调用函数
允许带有命名参数的函数被使用位置或命名记号法调用。
3.1. 使用位置记号
位置记号法是给函数传递参数的传统机制。
在位置记号法中,参数可以按照从右往左被忽略并且因此而得到默认值。
SELECT concat_lower_or_upper('Hello', 'World');
concat_lower_or_upper
-----------------------
hello world
(1 row)
所有参数被按照顺序指定。结果是大写形式,因为uppercase被指定为true:
SELECT concat_lower_or_upper('Hello', 'World', true);
concat_lower_or_upper
-----------------------
HELLO WORLD
(1 row)
3.2. 使用命名记号
每一个参数名都用=> 指定来把它与参数表达式分隔开。
使用命名记号法的一个优点是参数可以用任何顺序指定.
SELECT concat_lower_or_upper(a => 'Hello', b => 'World', uppercase => true);
concat_lower_or_upper
-----------------------
HELLO WORLD
(1 row)
SELECT concat_lower_or_upper(a => 'Hello', uppercase => true, b => 'World');
concat_lower_or_upper
-----------------------
HELLO WORLD
(1 row)
3.3. 使用混合记号
混合记号法组合了位置和命名记号法。命名参数不能超越位置参数。