我想为select语句创建存储过程,下面是我创建的过程,但它给出的数据输出为空白
CREATE OR REPLACE PROCEDURE public.deactivate_unpaid_accounts()
LANGUAGE 'sql'
AS $BODY$
select * from employees where salary=10000
$BODY$;
CALL deactivate_unpaid_accounts();
过程(在9.5开始时不提供)不打算返回结果集。
如果你想返回一个结果,你应该使用Postgres中的函数。
CREATE OR REPLACE FUNCTION public.deactivate_unpaid_accounts()
returns setof employees
LANGUAGE sql
AS $BODY$
select *
from employees
where salary=10000;
$BODY$;
然后像这样使用:
select *
from deactivate_unpaid_accounts();