Skip site navigation (1) Skip section navigation (2)

Re: create function problem

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Thomas Leung <thomasleung(at)hotmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: create function problem
Date: 2004-03-19 14:43:04
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-admin
On Tue, 16 Mar 2004, Thomas Leung wrote:

> I want to index my table using the year of the date. So I create the
> following function.
> create function to_year(date) returns varchar as '
> declare
>   str varchar;
>   begin
>     str := to_char($1, "YYYY");
>     return str;
>   end;
> ' language 'plpgsql' with (iscachable, isstrict);
> But I face the problem as follow
> select to_year(current_date);
> WARNING:  Error occurred while executing PL/pgSQL functions to_year
> WARNING:  line 4 at assignment
> ERROR:  Attribute "YYYY" not found
> Anybody can help? Thanks.

I think you're going towant doubled single quotes (''YYYY'') not double

In response to

pgsql-admin by date

Next:From: Stephan SzaboDate: 2004-03-19 14:48:33
Subject: Re: SOS ---- Could you help me with postgresql.....????
Previous:From: Bill MontgomeryDate: 2004-03-19 14:38:35
Subject: Re: unimplemented functions

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group