[DBTablesMonitoring] Fix a bug that getLastEventId() returns unexpected ...

...value

When no event exists, getLastEventId() returns 0 in spite of
expecting EVENT_NOT_FOUND.

In this commit we use a SQL function coalesce to avoid this issue.

Since getLastChangeTimeOfTrigger() has similar code, I also fixed
this function although it doesn't have such problem (because the
expected value is 0 for this case).