有两个使用相同模板的功能:
CREATE OR REPLACE FUNCTION public.rdxi(
mydate date DEFAULT (
(
'now'::text)::date - '1 day'::interval))
RETURNS TABLE("Date" date, "Nom" character varying, "Capacité (TB)" numeric, "Utilisé (TB)" numeric, "Charge (%)" text, "Données protégées (TB)" numeric, "Ratio" numeric)
LANGUAGE 'plpgsql'
COST 100
VOLATILE
ROWS 1000
AS $BODY$
BEGIN
RETURN QUERY
SELECT "rDxi"."Date", "rDxi"."Nom", "rDxi"."Capacité réelle en TB", "rDxi"."Utilisé en TB", "rDxi"."Charge", "rDxi"."Données protégées en TB", "rDxi"."Ratio"
from "rDxi" where "rDxi"."Date" = mydate;
END
$BODY$;
和
CREATE OR REPLACE FUNCTION public."rPower-Chassis-Ram"(
mydate date DEFAULT (
(
'now'::text)::date - '1 day'::interval))
RETURNS TABLE("Date" date, "Id" character varying, "Nom" character varying, "Cpu type" text, "Ram totale (GB)" numeric, "Ram libre (GB)" numeric, "Charge (%)" numeric)
LANGUAGE 'plpgsql'
COST 100
VOLATILE
ROWS 1000
AS $BODY$
BEGIN
RETURN QUERY
SELECT "rPower-Chassis-Ram"."Date", "rPower-Chassis-Ram"."Id", "rPower-Chassis-Ram"."Nom", "rPower-Chassis-Ram"."Type Cpu", "rPower-Chassis-Ram"."Ram Totale", "rPower-Chassis-Ram"."Ram_Libre",
"rPower-Chassis-Ram"."Charge"
from "rPower-Chassis-Ram" where "rPower-Chassis-Ram"."Date" = mydate;
END
$BODY$;
问第一个问题没问题,但是问第二个问题时,我收到以下错误消息:
ERROR: column reference "rPower-Chassis-Ram.Date" is ambiguous
LINE 1: SELECT "rPower-Chassis-Ram"."Date", "rPower-Chassis-Ram"."Id...
^
DETAIL: It could refer to either a PL/pgSQL variable or a table column.
QUERY: SELECT "rPower-Chassis-Ram"."Date", "rPower-Chassis-Ram"."Id", "rPower-Chassis-Ram"."Nom", "rPower-Chassis-Ram"."Type Cpu", "rPower-Chassis-Ram"."Ram Totale", "rPower-Chassis-Ram"."Ram_Libre",
"rPower-Chassis-Ram"."Charge"
from "rPower-Chassis-Ram" where "rPower-Chassis-Ram"."Date" = mydate
CONTEXT: PL/pgSQL function "rPower-Chassis-Ram"(date) line 3 at RETURN QUERY
État SQL :42702
不知道要在哪里进行调查,尝试更改函数的名称(用_代替),尝试使用不带特殊字符的普通名称重命名,但是没有办法...
答案 0 :(得分:0)
名称冲突发生在funcrion参数和列名称之间。
最简单的解决方案是避免名称冲突,例如通过调用OUT
参数p_date
。
或者,您可以使用表别名:
SELECT t."Date"
FROM aschema."SillyTableName" AS t
...