Re: Time stamp issue - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Time stamp issue
Date
Msg-id 20080110155334.GD29714@svana.org
Whole thread Raw
In response to Time stamp issue  (<kapil.munish@wipro.com>)
List pgsql-general
On Tue, Jan 08, 2008 at 08:21:40PM +0530, kapil.munish@wipro.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@svana.org>   http://svana.org/kleptog/
> Those who make peaceful revolution impossible will make violent revolution inevitable.
>  -- John F Kennedy

Attachment

pgsql-general by date:

Previous
From: Sim Zacks
Date:
Subject: Re: 8.2.4 serious slowdown
Next
From: "Isak Hansen"
Date:
Subject: Re: 8.2.4 serious slowdown