On Jan 8, 2008 8:51 AM, <kapil.munish@wipro.com> wrote:
> 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.
>
> I tried to cast it to a timestamp by using Timestamp timestamp = new
> Timestamp((java.sql.Date(rs.getTimestamp(time_stamp)).getTime());
When you subtract one timestamp from another, you get an interval, not
a timestamp. I.e. now() - (now() - 5 minutes) gives a result of 5
minutes.
So, you need to replace the ? with 5 minutes, so your query looks
something like this:
DELETE from CONCURRENT_USER WHERE (now() - CONCURRENT_USER.TIME_STAMP)
> interval '5 minutes'
or this:
DELETE from CONCURRENT_USER WHERE (now() - CONCURRENT_USER.TIME_STAMP)
> '5 minutes'::interval
or this:
DELETE from CONCURRENT_USER WHERE (now() - CONCURRENT_USER.TIME_STAMP)
> cast('5 minutes' as interval)