开发者

postgres - ERROR: syntax error at or near "COST"

EDIT Taking COST 100 out made the command go through, however, I'm still unable to run my query because it yields this error:

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.

The query I'm running is this:

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

This function seems to work fine locally, but moving it online yields this error... Is there something I'm missing?

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 j76开发者_如何学Pythondd3;


As the hint message states, you are missing an argument to your stored procedure. It expects 2 arguments, but in your column statments:

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        

you supply only one.

Since PostgreSQL 8.4 default values for arguments are allowed. Take a look at the reference for more information and examples.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜