Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id 87DFD2E0038 for ; Sat, 5 Apr 2008 14:59:48 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 80092-03 for ; Sat, 5 Apr 2008 14:59:16 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from QMTA03.emeryville.ca.mail.comcast.net (qmta03.emeryville.ca.mail.comcast.net [76.96.30.32]) by developer.postgresql.org (Postfix) with ESMTP id 2A39D2E002D for ; Sat, 5 Apr 2008 14:59:44 -0300 (ADT) Received: from OMTA06.emeryville.ca.mail.comcast.net ([76.96.30.51]) by QMTA03.emeryville.ca.mail.comcast.net with comcast id 9pkT1Z00316AWCUA30GA00; Sat, 05 Apr 2008 17:57:28 +0000 Received: from [192.168.0.2] ([67.160.97.168]) by OMTA06.emeryville.ca.mail.comcast.net with comcast id 9tzg1Z0073dyZyT8S00000; Sat, 05 Apr 2008 17:59:42 +0000 X-Authority-Analysis: v=1.0 c=1 a=BpT6EsQLgvcA:10 a=K1SLq9dmft0A:10 a=epTmVMiNAAAA:8 a=zAUM2DZmLUg0rDaDJSUA:9 a=YQgS98D464hnV9ELz_7U8r-rmCMA:4 a=si9q_4b84H0A:10 a=LY0hPdMaydYA:10 From: Adrian Klaver To: pgsql-sql@postgresql.org Subject: Re: Problem with now() in function pgsql Date: Sat, 5 Apr 2008 10:59:51 -0700 User-Agent: KMail/1.9.1 Cc: luke.78@libero.it References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200804051059.51195.aklaver@comcast.net> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/31 X-Sequence-Number: 30570 On Saturday 05 April 2008 10:46 am, luke.78@libero.it wrote: > Hi, > I have a problem in a function pgsql with Reading TIMESTAMP calling the > function now() the problem is this: > At the begin of function I read timestamp... > select now() into TS_BEGIN; > > the function execute some statement... > > Many seconds after I reread the timestamp > select now() into TS_END; > > and TS_BEGIN is identical TS_END!!! > > Can anyone help me? > > Thanks in advance. > > Luke. You want to use clock_timestamp() or equivalent not now(). As you found out now() fixes the time at the start of the transaction and does not change, clock_timestamp() does. See URL below for a more complete explanation: http://www.postgresql.org/docs/8.2/interactive/functions-datetime.html -- Adrian Klaver aklaver@comcast.net