常量

174
2023/08/01 16:55:53

简介

定义常量的语法:

常量名 constant 数据类型 := 初始值表达式;

示例

以下示例声明一个名为 vat(增值税)的常量,然后计算售价:

do $$ 
declare
   vat constant numeric := 0.1;
   net_price    numeric := 20.5;
begin
   raise notice 'The selling price is %', net_price * ( 1 + vat );
end $$;