答案 0 :(得分:1)
您错过了关键字as
。另外,count(*)
会返回bigint
,所以:
create function get_quantity()
returns bigint as $$
select count(*) from my_table;
$$ language sql;
或
create function get_quantity()
returns integer as $$
select count(*)::int from my_table;
$$ language sql;