X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 606A3D1DD0F for ; Fri, 19 Mar 2004 14:43:10 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 23176-03 for ; Fri, 19 Mar 2004 10:43:06 -0400 (AST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 0107CD1DC5D for ; Fri, 19 Mar 2004 10:43:02 -0400 (AST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 26F6435875; Fri, 19 Mar 2004 06:43:04 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 2581C35840; Fri, 19 Mar 2004 06:43:04 -0800 (PST) Date: Fri, 19 Mar 2004 06:43:04 -0800 (PST) From: Stephan Szabo To: Thomas Leung Cc: pgsql-admin@postgresql.org Subject: Re: create function problem In-Reply-To: Message-ID: <20040319064220.W75424@megazone.bigpanda.com> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/257 X-Sequence-Number: 12826 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 quotes.