0
我有一个Postgres VIEW,它使用plpgsql函数四次来生成一个陈旧的债务报告。如果行在当前时间段中有一个日期,则该行中的值进入列1,如果日期是上个月,则该值在列2中...等等。
我用参数调用函数,该参数告诉函数计算本月债务,上个月债务,债务2个月以前的债务 - 或者在最后一列之前的所有内容。我可以更改PostgreSQL函数中的列标题吗?
CREATE OR REPLACE FUNCTION agedebt4(beforem integer, d_details)
RETURNS double precision AS
$BODY$
/* This Func creates a column for Aged Debt Reporting from d_details table
The beforem parameter can be entered as 0,1,2 or 3
0 shows current period debt, 1 previous period, 2 cur period -2
and 3 shows current period less three AND EARLIER. */
DECLARE
curdt date =(CURRENT_DATE);
curdy text = substring(curdt,1,4);
curdm text = substring(curdt,6,2);
curdmi int = curdm::int;
curdyi int = curdy::int;
-- blah
-- blah
-- blah
视图有
SELECT agedebt4(0,d_details) AS "Current Debt", agedebt4(1,d_details)
AS "CurrPeriod -1 Debt", agedebt4(2,d_details) AS "CurrPeriod -2 Debt", -- etc
但我希望有列标题改变了里面的功能。所以我实际上可以有Oct2013 Debt
Sep2013 Debt
Aug2013 Debt
July2013+
Earlier
...(显然月份名称取决于执行月份)...在输出中显示。我不想从agedebt4更改函数名称 - 没关系。我希望函数修改显示的列标题。
可以这样做吗?