Fixing SQL exception.