1

i tried to write a named query in my Entity Java Bean class , and tried also to write the same query as a native query , its job is to delete records which difference between their timestamp column and current time stamp, are greater than 2 hours.

my query :

DELETE FROM APP.WEATHER WHERE timestampdiff(SQL_TSI_HOUR,APP.WEATHER.SINCE,CURRENT_TIMESTAMP) > 2;

but it failed , and this error message appeared to me :

Error code -1, SQL state 42X04: Column 'SQL_TSI_HOUR' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE  statement then 'SQL_TSI_HOUR' is not a column in the target table.
Line 1, column 1
Jason4Ever
  • 1,439
  • 4
  • 23
  • 43
  • 3
    take a look at this question that shows the usage of [timestampdiff][1]. [1]: http://stackoverflow.com/questions/11511805/using-timestampdiff-in-a-derby-where-clause – Yazan Jaber Jan 14 '14 at 01:03

0 Answers0