Debugging problems storing SQL statement in table