【发布时间】:2014-04-25 15:37:02
【问题描述】:
如果我有一个函数只返回一行,其中包含表中的一些列,我是否需要在函数返回声明中添加%rowtype?
CREATE OR REPLACE FUNCTION test(int n)
RETURNS tableName%rowtype AS
$BODY$
DECLARE
r tableName%rowtype;
BEGIN
select a,b,c into r from tableName where d=n;
return r;
$BODY$
END;
【问题讨论】:
-
这看起来不对 -
tableName%rowtype应该包含tableName中的所有列,而不仅仅是您选择的那些。
标签: database postgresql plpgsql