Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 0BD2C9FB2C4 for ; Thu, 18 Jan 2007 20:11:01 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 64511-09 for ; Thu, 18 Jan 2007 20:10:57 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.186]) by postgresql.org (Postfix) with ESMTP id 0D7A49FB2BB for ; Thu, 18 Jan 2007 20:10:56 -0400 (AST) Received: by nf-out-0910.google.com with SMTP id x4so342168nfb for ; Thu, 18 Jan 2007 16:10:55 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=a6MX/qHSxDDmoi9n1Ijqq/CSjRlwLg0uEnwXEW2IFLf++UvpfZ7RvLwF5e0+YJggGCXhD8Riw8v0Z8jWjaTiN8LNHCDqZfo8cpsqfKLqYHlQxWeirHRdj83hZN01eBS+2X7TNiWdv2dX4N7JDmfD4b3SXTGhJ3KO0qyUABOiwvY= Received: by 10.49.8.15 with SMTP id l15mr1541503nfi.1169165455415; Thu, 18 Jan 2007 16:10:55 -0800 (PST) Received: by 10.48.230.1 with HTTP; Thu, 18 Jan 2007 16:10:55 -0800 (PST) Message-ID: <81961ff50701181610w6428119dke98d9fc52fa90a1c@mail.gmail.com> Date: Thu, 18 Jan 2007 19:10:55 -0500 From: "Chad Wagner" To: "Negandhi, Nishith" Subject: Re: System Date Cc: "Benjamin Krajmalnik" , pgsql-admin@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_1077_2731916.1169165455334" References: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/165 X-Sequence-Number: 24321 ------=_Part_1077_2731916.1169165455334 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 1/18/07, Negandhi, Nishith wrote: > > Hi Thanx..one more help. > I am creating a function that will retuen the current systemdate. > > CREATE FUNCTION "CreateDate"() RETURNS date AS > 'select now();' > LANGUAGE 'plpgsql'; > > However, I get the error: > > ERROR: syntax error at or near "select" at character 51 > > Any suggestions .?? > > Thanks in advance > Syntax is wrong, although I fail to see why you don't just use the "NOW()" function. I guess I will assume this is just an example. :) CREATE OR REPLACE FUNCTION "CreateDate"() RETURNS DATE AS $$ DECLARE var_date date; BEGIN SELECT NOW() INTO var_date; RETURN var_date; END; $$ LANGUAGE 'plpgsql'; -- Chad http://www.postgresqlforums.com/ ------=_Part_1077_2731916.1169165455334 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 1/18/07, Negandhi, Nishith <Nishith.Negandhi@infousa.com> wrote:
Hi Thanx..one more help.
I am creating a function that will retuen the current systemdate.
 
CREATE FUNCTION "CreateDate"() RETURNS date AS
'select now();'
LANGUAGE 'plpgsql';
 
However, I get the error:
 
ERROR:  syntax error at or near "select" at character 51
 
Any suggestions .??
 
Thanks in advance

Syntax is wrong, although I fail to see why you don't just use the "NOW()" function.  I guess I will assume this is just an example.  :)

CREATE OR REPLACE FUNCTION "CreateDate"()
RETURNS DATE AS
$$
DECLARE
   var_date date;
BEGIN
   SELECT NOW()
     INTO var_date;

   RETURN var_date;
END;
$$ LANGUAGE 'plpgsql';



--
Chad
http://www.postgresqlforums.com/ ------=_Part_1077_2731916.1169165455334--