Re: syntax for using function parameter in to_char - Mailing list pgsql-sql

From Josh Berkus
Subject Re: syntax for using function parameter in to_char
Date
Msg-id web-682424@davinci.ethosmedia.com
Whole thread Raw
In response to syntax for using function parameter in to_char  (Kevin Barrett <anon000000@hotmail.com>)
List pgsql-sql
Kevin,

> CREATE FUNCTION java_date( bigint ) RETURNS text AS '
>     select to_char(\'epoch\'::datetime + \'$1 seconds\'::interval, 
> \'dd/mm/yyyy hh:mi\') as RESULT
>   '
>   LANGUAGE 'sql';

Try this instead:
CREATE FUNCTION java_date( bigint ) RETURNS text AS '      select to_char(''epoch''::datetime +              (CAST($1
ASVARCHAR) || ''seconds'')::interval,               ''dd/mm/yyyy hh:mi'') as RESULT
 
'
LANGUAGE 'sql';

Got it?  Check, though, a "CAST (bigint as varchar)" may or may notwork.

-Josh



______AGLIO DATABASE SOLUTIONS___________________________                                      Josh Berkus Complete
informationtechnology      josh@agliodbs.com  and data management solutions       (415) 565-7293 for law firms, small
businesses       fax 621-2533   and non-profit organizations.      San Francisco
 


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: pg_vlock / vacuum
Next
From: Tom Lane
Date:
Subject: Re: NOTICE: Vacuum: can not process indices, views and certain system tables