我在Postgres上使用SQL语言使用RETURNS TABLE命令返回表:
CREATE OR REPLACE FUNCTION procreadbudget()
RETURNS TABLE(budgetmonth character, budgetincome numeric, budgetexpense numeric) AS
$BODY$
SELECT budget_month, budget_income, budget_expense FROM budget ORDER BY unique_id;
$BODY$
LANGUAGE 'sql' VOLATILE
所有数据均以逗号分隔的字符串而不是表格形式返回:
"(Jan,1123,1201)"
"(Feb,1098,996)"
"(Mar,1545,1345)"
"(Apr,1564,1952)"
"(May,1123,990)"
"(Jun,1345,1234)"
"(Jul,1234,878)"
"(Aug,1139,1187)"
"(Sep,1076,1123)"
"(Oct,873,956)"
"(Nov,1298,1423)"
"(Dec,1123,1324)"
有任何建议,
麦克风
最佳答案
用
SELECT * FROM procreadbudget();
代替
SELECT procreadbudget();
关于postgresql - postgres "Returns Table"返回一个字符串,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3316438/