Cro*_*les 1 postgresql stored-procedures
我有一个存储过程,如下所示。我一直认为最后一个选择的结果会自动返回,但我收到这个错误,我不知道为什么,有人能启发我吗?
CREATE OR REPLACE FUNCTION pGetPlans() RETURNS TABLE (
title varchar(16),
full_cost money,
subtitle varchar(128),
blurb varchar(128),
details varchar(128)[],
final_str text)
AS $$
DECLARE
full_cost tplan.cost%TYPE;
current_cost tplan.cost%TYPE;
amount_saved tplan.cost%TYPE;
percent_saved float;
monthly_cost tplan.cost%TYPE;
one_month_cost tplan.cost%TYPE;
you_save tplan.cost%TYPE;
BEGIN
select
cost
into
one_month_cost
from
tplan
where
is_base = true;
select
p.title,
p.cost,
p.subtitle,
p.blurb,
p.details,
'1 Month Cost is: ' || one_month_cost::text as final_str
from
tplan p
where
p.status = 'A';
END;
$$ LANGUAGE plpgsql;
Run Code Online (Sandbox Code Playgroud)
谢谢克鲁兹