Re: PGsql function timestamp issue

From: "Jonathan S(dot) Katz" <jonathan(dot)katz(at)excoventures(dot)com>
To: ng <pipelines(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: PGsql function timestamp issue
Date: 2014-05-29 20:52:32
Message-ID: A7B82A97-96B4-4ED2-8F2E-FDED9C6F19EC@excoventures.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On May 29, 2014, at 4:46 PM, ng <pipelines(at)gmail(dot)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:

http://www.postgresql.org/docs/current/static/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT

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

Jonathan

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Steve Crawford 2014-05-29 21:13:02 Re: PGsql function timestamp issue
Previous Message ng 2014-05-29 20:46:59 PGsql function timestamp issue