PostgreSQL plpgsql函数有可能不返回任何内容吗?我创建了一个函数,我不需要它返回任何东西,因为它执行复杂的SQL查询,并将该查询的结果插入另一个表(SELECT INTO ....) . 因此,我没有必要或有兴趣让函数返回任何输出或值 . 不幸的是,当我尝试省略函数声明的RETURN子句时,我无法创建该函数 . PostgreSQL plpgsql函数有可能不返回任何内容吗?
是的 - "If the function is not supposed to return a value, specify void as the return type."以及 - "If you declared the function to return void, a RETURN statement can be used to exit the function early; but do not write an expression following RETURN." .
如果您有一个或多个 OUT 输出参数,则不需要 RETURN 子句 . 这显然是回归了一些东西,但是如你所说,允许你回事 .
OUT
RETURN
不,它必须至少返回 null . 来自PostgreSQL documentation:
null
触发器函数必须返回NULL或具有与触发器触发的表的结构完全相同的记录/行值 .
3 回答
是的 - "If the function is not supposed to return a value, specify void as the return type."以及 - "If you declared the function to return void, a RETURN statement can be used to exit the function early; but do not write an expression following RETURN." .
如果您有一个或多个
OUT
输出参数,则不需要RETURN
子句 . 这显然是回归了一些东西,但是如你所说,允许你回事 .不,它必须至少返回
null
. 来自PostgreSQL documentation: