INSERT INTO ... RETURNING - 不明确的列引用 [英] INSERT INTO ... RETURNING - ambiguous column reference

查看:70
本文介绍了INSERT INTO ... RETURNING - 不明确的列引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Can someone politely explain this craziness?

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

抛出一个模棱两可的引用错误,但它可以正确执行:

throws an ambiguous reference error, however this correctly executes:

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

_UserProfileId 是一个声明的整数变量.我在手册中找不到任何对这种语法的引用,或者为什么这会以任何方式产生歧义.

_UserProfileId is a declared integer variable. I couldn't find any references to this syntax in the manual or why on earth this would be ambiguous in any way.

推荐答案

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

IN and OUT parameters (including columns in RETURNS TABLE) are visible inside every SQL command in the body of a plpgsql function.

如果查询中有同名的列,则必须对它们进行表限定以使其明确无误.在你的情况下,表名会做:

If you have columns of the same name in your query, you have to table-qualify them to make it unambiguous. In your case, the table name would do:

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

手册中的详细信息.

相关:

这篇关于INSERT INTO ... RETURNING - 不明确的列引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆