Re: PGsql function timestamp issue

From: Vinayak Pokale <vinpokale(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: PGsql function timestamp issue
Date: 2014-07-25 08:59:12
Message-ID: 1406278752273-5812825.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-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.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Andreas Joseph Krogh 2014-07-29 09:52:12 Update columns in the same table in a deferred constraint trigger
Previous Message Benjamin Dugast 2014-07-24 08:36:17 Re: Is CREATE TABLE non-blocking ?