1
的作品我有这样的功能:整数数组PLPGSQL抛出错误在PostgreSQL的9.1,但9.3
CREATE OR REPLACE FUNCTION check_presence_row(
_id_att_files integer[],
_people_name character varying,
_people_id character varying,
_time_start timestamp without time zone,
_time_end timestamp without time zone
)
RETURNS integer[] AS $BODY$
DECLARE
ids integer array;
BEGIN
ids := (SELECT "id_att_file"FROM att_presence WHERE
"id_att_file" = ANY ("_id_att_files") AND
"id_people" = get_people(
"_people_id",
"_people_name") AND
"time_start" = "_time_start" AND
"time_end" = "_time_end");
RETURN ids;
END;$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
当我把它在PostgreSQL的版本9.3
这样:
SELECT check_presence_row(
CAST ('{1,4}' AS int[]),
CAST ('Random Guy' AS varchar),
CAST ('D0388A' AS varchar),
CAST ('2014/08/23 8:04:00' AS timestamp without time zone),
CAST ('2014/08/23 8:34:00' AS timestamp without time zone)
);
它运行正常,并根据需要返回结果,但在9.1
当我发送相同的查询时会抛出一个错误:
ERROR: array value must start with "{" or dimension information
CONTEXT: PL/pgSQL function "check_presence_row" line 5 at assignment
********** Error **********
ERROR: array value must start with "{" or dimension information
SQL state: 22P02
Context: PL/pgSQL function "check_presence_row" line 5 at assignment
我发现,当该数组的任何输入值正好是1
它以这种方式失败,但如果我将它们更改为一些不同的整数值传递....但只在我的本地主机。我们的生产服务器仍然无法通过任何价值。我们尝试了另一台计算机,即使值为1
,也通过了一台计算机。有任何想法吗?
奇怪的问题。你认为你可以简化为http://sqlfiddle.com/? – 2014-09-25 14:19:56
没关系,我只是找到了原因。它是由那个id:= assignemnt引起的,因为我在att_files中只有一行(这就是为什么在我的电脑上它与I 1失败) – 2014-09-25 14:57:56
很好的自我回答。 – 2014-09-25 15:04:58