fixed bug that SQL function was not being called because of no DB connection