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

Posted by cino21122 on Stack Overflow See other posts from Stack Overflow or by cino21122
Published on 2010-04-19T06:34:43Z Indexed on 2010/04/19 6:43 UTC
Read the original article Hit count: 433

Filed under:
|
|

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 j76dd3;

© Stack Overflow or respective owner

Related posts about postgres

Related posts about function