Can't convert numeric to_char() in catenate function

From: Yusuf <yusufad(at)myrealbox(dot)com>
To: PgSql-SQL <pgsql-sql(at)postgresql(dot)org>
Subject: Can't convert numeric to_char() in catenate function
Date: 2003-10-16 22:24:16
Message-ID: 20031016222416.672C5D1B4E8@svr1.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


Hi there.

Im trying to do the usual row catenation function, but for a "numeric" type column. I have this:

CREATE OR REPLACE FUNCTION "verticat" (text, numeric) RETURNS text AS '
SELECT CASE WHEN $2 IS NULL THEN $1
WHEN $1 IS NULL OR $1 = ''''
THEN to_char($2,'999999999D99')
ELSE $1 || '', '' || to_char($2,'99999999D99')
END
' LANGUAGE 'sql';

This works without problem with "float" or other type with direct casting to text (after replacing the "to_char(...)" with $2::text), but this one gives me an "ERROR: parser: parse error at or near "999999999""... wath is wrong with it??

It would also be nice to trim the spaces placed by to_char, with something like "ltrim(' ', to_char($2,'999999999D99'))", but that yields yet anoter error: "ERROR: parser: parse error at or near "'"".

Any help 'preciated. Thanks!

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message 2000info 2003-10-16 22:53:12 Postgres with OpenSSL
Previous Message Olga Macias 2003-10-16 17:59:04 Add column with specific colid