I have defined a rule to check the lastUpdate value for an item like so, but the value is always returned null:
rule "test db"
when
Time cron "5 * * * * ?"
then
if( light1.lastUpdate != null ) {
… stuff here …
}
end
This appears to be because the SQL being executed is incorrect. The “OFFSET 1 ROWS” means the query misses the most recent update. Have I assessed this correctly?
13:13:05.365 [DEBUG] [o.p.j.i.JdbcPersistenceService:162 ] - JDBC::query: item is light1
13:13:05.365 [DEBUG] [o.o.p.jdbc.internal.JdbcMapper:142 ] - JDBC::getHistItemFilterQuery filter=‘true’ numberDecimalcount=‘3’ table=‘item0003’ item=‘light1 (Type=SwitchItem, State=Uninitialized)’ itemName='light1’
13:13:05.366 [DEBUG] [rsistence.jdbc.db.JdbcDerbyDAO:175 ] - JDBC::getHistItemFilterQueryProvider filter = FilterCriteria [itemName=light1, beginDate=null, endDate=null, pageNumber=0, pageSize=1, operator=EQ, ordering=DESCENDING, state=null], numberDecimalcount = 3, table = item0003, simpleName = light1
13:13:05.366 [DEBUG] [rsistence.jdbc.db.JdbcDerbyDAO:221 ] - JDBC::query queryString = SELECT time, value FROM ITEM0003 ORDER BY time DESC OFFSET 1 ROWS FETCH FIRST 1 ROWS ONLY
13:13:05.367 [DEBUG] [rsistence.jdbc.db.JdbcDerbyDAO:152 ] - JDBC::doGetHistItemFilterQuery gor Array length=0
13:13:05.367 [DEBUG] [o.p.j.i.JdbcPersistenceService:203 ] - JDBC::query: query for light1 returned 0 rows in 2ms