agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Vinayak Pokale <vinpokale@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: PGsql function timestamp issue
Date: Fri, 25 Jul 2014 01:59:12 -0700 (PDT)
Message-ID: <1406278752273-5812825.post@n5.nabble.com> (raw)
In-Reply-To: <CAAQKod115J-w7hiJ+rG8kn2FVqW51+ZVJsVpELNcU1Q4cw69dQ@mail.gmail.com>
References: <CAAQKod115J-w7hiJ+rG8kn2FVqW51+ZVJsVpELNcU1Q4cw69dQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

Hello,

The current_timestamp return the constant value in a transaction. So use
clock_timestamp().
Example:
create or replace function fx_nish()
returns text
  language plpgsql
  as
$$
declare
x timestamp with time zone;
y timestamp with time zone;
begin
x:= clock_timestamp();
perform pg_sleep(5);
y:= clock_timestamp();
if x=y then
return 'SAME';
else
return 'DIFFERENT';
end if;

end;
$$
;
postgres=# select fx_nish();
  fx_nish  
-----------
 DIFFERENT
(1 row)




-----
Thanks and Regards,
Vinayak Pokale,
NTT DATA OSS Center Pune, India
--
View this message in context: http://postgresql.1045698.n5.nabble.com/PGsql-function-timestamp-issue-tp5805486p5812825.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (5+ messages)

Message-ID: <1406278752273-5812825.post@n5.nabble.com>
Permalink:  ../1406278752273-5812825.post@n5.nabble.com/
Also on:    postgresql.org/message-id/1406278752273-5812825.post@n5.nabble.com

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: vinpokale@gmail.com
  Subject: Re: PGsql function timestamp issue
  In-Reply-To: <1406278752273-5812825.post@n5.nabble.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox