Fixed bug in SQL.

Fixed a potential bug identified by FindBugs.