Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wq7Jp-0006tK-7M for pgsql-sql@arkaria.postgresql.org; Thu, 29 May 2014 20:52:57 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Wq7Jm-0006R9-CQ for pgsql-sql@arkaria.postgresql.org; Thu, 29 May 2014 20:52:54 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Wq7Ja-0006Jy-Qz for pgsql-sql@postgresql.org; Thu, 29 May 2014 20:52:42 +0000 Received: from mail-qg0-f44.google.com ([209.85.192.44]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1Wq7JV-0001ws-Td for pgsql-sql@postgresql.org; Thu, 29 May 2014 20:52:39 +0000 Received: by mail-qg0-f44.google.com with SMTP id i50so2712862qgf.17 for ; Thu, 29 May 2014 13:52:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:content-type:mime-version:subject:from :in-reply-to:date:cc:message-id:references:to; bh=7B24X/JhIrpvZ/CeBgdnyd3wzXt/1PtVneeolAnAkSM=; b=DvsLfg61j5X0P8zzdUVn85f2mK3SufxZes6cqBCPUGzr88Hw4icWruOcwJhks8wNcB jmEkOeCKMxs2sv7OrEFe37wIV7/mTwju6vjLogLFLGaLN425/1pqBp5Iw78eUcAsrN8O K+swCyDV2YoqqhZBieWi+aCB36epdhsgydaTa6DGvFMJNdmXan3L7YjOKibt9uqCTtyN l+Sz9iIxElGSQql5C3fWg+ssZK6SnoKQAa/ghLZr0iu1MkWaZWojAafqRy1pClfq+nbo En/t8wHWUb8f/c7hDT6toRfoSle0kUf1m2ffKJjER0DnsbtYRoXu/h/gRWMtqnTgnCZX T/8g== X-Gm-Message-State: ALoCoQnZxulHHChe6LC6fzf1N5446arLyytzBMZXGafoM2Ea9G3RucezP/Haor5WpW9VonjnbDCc X-Received: by 10.140.50.168 with SMTP id s37mr13743235qga.36.1401396757001; Thu, 29 May 2014 13:52:37 -0700 (PDT) Received: from ph33r-retina.home (pool-100-2-123-241.nycmny.fios.verizon.net. [100.2.123.241]) by mx.google.com with ESMTPSA id b10sm1079472qgf.7.2014.05.29.13.52.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 May 2014 13:52:34 -0700 (PDT) Content-Type: multipart/alternative; boundary="Apple-Mail=_BD102488-0FF8-4C34-A365-484F123533AB" Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) Subject: Re: PGsql function timestamp issue From: "Jonathan S. Katz" In-Reply-To: Date: Thu, 29 May 2014 16:52:32 -0400 Cc: pgsql-sql@postgresql.org Message-Id: References: To: ng X-Mailer: Apple Mail (2.1874) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org --Apple-Mail=_BD102488-0FF8-4C34-A365-484F123533AB Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On May 29, 2014, at 4:46 PM, ng wrote: > create or replace function dw.fx_nish()=20 > returns text > language plpgsql > as > $$ > declare > x timestamp with time zone; > y timestamp with time zone; > begin > x:=3D current_timestamp; > perform pg_sleep(5);=20 > y:=3D current_timestamp; > if x=3Dy then=20 > return 'SAME'; > else > return 'DIFFERENT'; > end if; >=20 > end; > $$ >=20 >=20 > select dw.fx_nish() > This give me 'SAME' >=20 > Any work around for this? Check out the Current Date/Time section: = http://www.postgresql.org/docs/current/static/functions-datetime.html#FUNC= TIONS-DATETIME-CURRENT You probably want "clock_timestamp()" depending on what you are trying = to accomplish. Jonathan= --Apple-Mail=_BD102488-0FF8-4C34-A365-484F123533AB Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii On May 29, 2014, at 4:46 PM, ng <pipelines@gmail.com> wrote:

create or replace function dw.fx_nish()
returns text
  language plpgsql
  as
$$
declare
x timestamp with time zone;
y timestamp with time zone;
begin
x:= current_timestamp;
perform pg_sleep(5);
y:= current_timestamp;
if x=y then
return 'SAME';
else
return 'DIFFERENT';
end if;

end;
$$


select dw.fx_nish()
This give me 'SAME'

Any work around for this?

Check out the Current Date/Time section:


You probably want "clock_timestamp()" depending on what you are trying to accomplish.

Jonathan
--Apple-Mail=_BD102488-0FF8-4C34-A365-484F123533AB--