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

create function problem

From: "Thomas Leung" <thomasleung(at)hotmail(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: create function problem
Date: 2004-03-16 04:02:24
Message-ID: BAY8-F86Mma0n7J95K700001d87@hotmail.com (view raw or flat)
Thread:
Lists: pgsql-admin
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.

_________________________________________________________________
Linguaphone :  Learning English? Get Japanese lessons for FREE 
http://go.msnserver.com/HK/30476.asp


Responses

pgsql-admin by date

Next:From: Erwin BrandstetterDate: 2004-03-16 08:43:34
Subject: Re: Hardware for a database server
Previous:From: Tom LaneDate: 2004-03-15 22:07:09
Subject: Re: nodeRead: did not find '}' at end of plan node

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