编辑使用COST 100使命令通过,但是,我仍然无法运行查询,因为它会产生此错误:
ERROR: function group_concat(character) does not exist
HINT: No function matches the given name and argument types. You may need to add explicit type casts.
我正在运行的查询是:
select tpid, group_concat(z) as z,
group_concat(cast(r as char(2))) as r,
group_concat(to_char(datecreated,'DD-Mon-YYYY HH12:MI am')) as datecreated,
group_concat(to_char(datemodified,'DD-Mon-YYYY HH12:MI am')) as datemodified
from tpids group by tpid order by tpid, zip
这个功能似乎在本地工作正常,但在线移动会产生这个错误......有什么我不知道的吗?
CREATE OR REPLACE FUNCTION group_concat(text, text)
RETURNS text AS
$BODY$
SELECT CASE
WHEN $2 IS NULL THEN $1
WHEN $1 IS NULL THEN $2
ELSE $1 operator(pg_catalog.||) ',' operator(pg_catalog.||) $2
END
$BODY$
LANGUAGE 'sql' IMMUTABLE
COST 100;
ALTER FUNCTION group_concat(text, text) OWNER TO j76dd3;
答案 0 :(得分:1)
正如提示消息所述,您缺少存储过程的参数。它需要2个参数,但在您的列声明中:
group_concat(cast(r as char(2))) as r,
group_concat(to_char(datecreated,'DD-Mon-YYYY HH12:MI am')) as datecreated,
group_concat(to_char(datemodified,'DD-Mon-YYYY HH12:MI am')) as datemodified
你只提供一个。
因为PostgreSQL 8.4允许参数的默认值。请查看reference以获取更多信息和示例。