Re: Time stamp issue

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: kapil(dot)munish(at)wipro(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Time stamp issue
Date: 2008-01-10 15:53:34
Message-ID: 20080110155334.GD29714@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Jan 08, 2008 at 08:21:40PM +0530, kapil(dot)munish(at)wipro(dot)com wrote:
> The query is something like :
>
> DELETE from CONCURRENT_USER WHERE (now() - CONCURRENT_USER.TIME_STAMP) >
> ?
>
> Here the calculated value in '?' is not supported by the postgres as it
> was set as a double.

In postgres subtracting two timestamps produces an interval. If you
want to pass your parameter in seconds, try:

DELETE from CONCURRENT_USER WHERE (now() - CONCURRENT_USER.TIME_STAMP) > (? * '1 second'::interval)

Or if the use of indexes is important to you:

DELETE from CONCURRENT_USER WHERE CONCURRENT_USER.TIME_STAMP < (now() - (? * '1 second'::interval));

Perhaps JDBC can handle intervals itself also, that I don't know.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Those who make peaceful revolution impossible will make violent revolution inevitable.
> -- John F Kennedy

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Isak Hansen 2008-01-10 15:54:15 Re: 8.2.4 serious slowdown
Previous Message Clodoaldo 2008-01-10 15:50:42 Re: 8.2.4 serious slowdown