Hopefully you’re not trying to update based off the invented post ID – If you can you should let WordPress create IDs for new posts ( which it does in MySQL ) otherwise you’ll surely run into issues down the road.
Difficult to suggest the best course of action without the context of the rest of the code block.