Updated debug messages to output SQL errors