I have two columns in my table, Created(TIMESTAMP) and lifetime(BIGINT). Lifetime is represented as seconds. I would like to add the lifetime column to the timestamp column and compare that result to another date.
I referenced the derby manual and found support for TIMESTAMPADD in the "JDBC escape syntax for fn keyword" section:
{fn functionCall} TIMESTAMPADD( interval, integerExpression, timestampExpression )
Okay so I tried:
SELECT i.messageId FROM ServerMessageEntity i
WHERE {fn TIMESTAMPADD(SQL_TSI_SECOND, i.lifetime, i.created)} > :now
*:now is a parameter I pass in by:
query.setParameter
Unfortunitly I get the following exception:
Exception Description: Syntax error parsing the query [SELECT i.messageId FROM ServerMessageEntity i WHERE {fn TIMESTAMPADD(SQL_TSI_SECOND, i.lifetime, i.created)} > :now], unexpected char [{].
It seems like the solution would be to add the seconds to the created timestamp and have the result be another timestamp. Any help or syntax for how to do this would be appreciated. Thanks!
Other information: I am using Oracle TopLink 12c (12.1.2) for ORM and Derby 10.10.2.0