Re: System Date - Mailing list pgsql-admin

From Chad Wagner
Subject Re: System Date
Date
Msg-id 81961ff50701181610w6428119dke98d9fc52fa90a1c@mail.gmail.com
Whole thread Raw
In response to Re: System Date  ("Negandhi, Nishith" <Nishith.Negandhi@infoUSA.com>)
List pgsql-admin
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/

pgsql-admin by date:

Previous
From: "Negandhi, Nishith"
Date:
Subject: Re: System Date
Next
From: "Negandhi, Nishith"
Date:
Subject: Error in trigger