Postgres的 - 错误:在语法错误或接近“成本”

问题描述:

编辑以COST 100所作出的命令经历,但是,我仍然无法运行我的查询,因为它产生这样的错误:Postgres的 - 错误:在语法错误或接近“成本”

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; 

由于提示消息指出您缺少存储过程的参数。它期望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了解更多信息和示例。