Re: PGsql function timestamp issue - Mailing list pgsql-sql

From Vinayak Pokale
Subject Re: PGsql function timestamp issue
Date
Msg-id 1406278752273-5812825.post@n5.nabble.com
Whole thread Raw
In response to PGsql function timestamp issue  (ng <pipelines@gmail.com>)
List 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.



pgsql-sql by date:

Previous
From: Benjamin Dugast
Date:
Subject: Re: Is CREATE TABLE non-blocking ?
Next
From: Andreas Joseph Krogh
Date:
Subject: Update columns in the same table in a deferred constraint trigger