Hi Francesco,
what you're missing here is the Moodle completion cache: you can't update the DB w/o syncing the cache too. Try purging the caches in Moodle and the completion should "appear" as expected.
What about to update the completion status by means of a Web Service call? Give core_completion_update_activity_completion_status_manually a try, if it fits with your course/module settings.
More details in https://docs.moodle.org/dev/Web_service_API_functions.
HTH,
Matteo