INSERT INTO ... RETURNING - 不明确的列引用

INSERT INTO ... RETURNING - ambiguous column reference

有人可以礼貌地解释一下这种疯狂吗?

INSERT INTO "dbo"."UserProfile" ("FirstName")
VALUES('John')
RETURNING "UserProfileId" INTO _UserProfileId;

抛出一个不明确的引用错误,但是这正确执行:

INSERT INTO "dbo"."UserProfile" ("FirstName")
VALUES('John')
RETURNING "dbo"."UserProfile"."UserProfileId" INTO _UserProfileId;

_UserProfileId 是声明的整型变量。我在手册中找不到任何对这种语法的引用,也找不到为什么这在任何方面都是模棱两可的。

INOUT 参数(包括 RETURNS TABLE 中的列)在 plpgsql 函数主体的每个 SQL 命令中可见。

如果您的查询中有同名的列,则必须对它们进行 table 限定以使其明确无误。在您的情况下,table 名称可以:

... RETURNING "UserProfile"."UserProfileId" INTO _UserProfileId;

Details in the manual here.

相关: