Upon considering the demurrer, the court must make an order either overruling or sustaining it. If the demurrer to an indictment or information is overruled, the court must permit the defendant, at the defendant’s election, to plead, which the defendant must do forthwith, unless the court extends the time. If the demurrer is sustained, the court must, if the defect can be remedied by amendment, permit the indictment or information to be amended, either forthwith or within such time, not exceeding 10 days, as it may fix, or, if the defect or insufficiency therein cannot be remedied by amendment, the court may direct the filing of a new information or the submission of the case to the same or another grand jury. If the demurrer to a complaint is sustained, the court must, if the defect can be remedied, permit the filing of an amended complaint within such time not exceeding 10 days as it may fix. The orders made under this section shall be entered in the docket or minutes of the court.