Repairing an sqlite statement