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