Add check for transaction id before calling SQL request

This PR is to check that the transaction ID is present before calling the SQL request; if the value is false, a SQL error "boolean != text" is returned, and the transaction block is rollbacked for the remainder of the auto-completion.