(PDB-660) Wrap old resource & event query->sql in transacted connection

The older query->sql code for resources needs an open transaction to perform
a lookup needed for array comparison.

This also applies to the existing query->sql code for events.

This wraps just that code in a transaction, since its only really needed for
the older API versions this will eventually be retired.

Signed-off-by: Ken Barber <ken@bob.sh>