-- 返回integer类型数据
CREATE OR REPLACE FUNCTION public.mycount3()
RETURNS integer
LANGUAGE plpgsql
AS $function$
declare
mysql text;
counts integer;
begin
mysql:='select count("show_msg") from "sector"';
execute mysql into counts;
return counts;
end;
$function$
;
--返回一个表
CREATE OR REPLACE FUNCTION public.selectsector()
RETURNS setof sector
language plpgsql
AS $function$
declare
sql text;
begin
return query select * from "sector" limit 5;
end;
$function$
;
创建和方法名和返回模块
funtion模块
声明变量
执行语句模块
调用 select selectsector()