
188 Cal.App.3d 586 (1986)
233 Cal. Rptr. 204
THE PEOPLE, Plaintiff and Respondent,
v.
ANGEL LUIS GONZALES, Defendant and Appellant.
Docket No. F004880.
Court of Appeals of California, Fifth District.
December 31, 1986.
*587 COUNSEL
Frank O. Bell, Jr., State Public Defender, under appointment by the Court of Appeal, and Susana Halfron, Deputy State Public Defender, for Defendant and Appellant.
*588 John K. Van de Kamp, Attorney General, Roger E. Venturi and Anthony L. Dicce, Deputy Attorneys General, for Plaintiff and Respondent.
OPINION
BROWN (G.A.), P.J.
The issues raised in this appeal are limited to noncompliance by the trial court with Penal Code section 1192.6,[1],[2] requiring the prosecuting attorney to provide a statement of reasons on the record for his recommendation that the court accept a proposed negotiated plea, and the violation of section 1192.7[3] prohibiting plea bargaining in cases of serious felonies unless the case falls within one of three exceptions.
The issues being so limited, a sufficient statement of the facts is simply to relate that about 9 p.m. one evening the victim answered the door of his apartment and was confronted by two men. One of the men, later identified as appellant, said "This is from Lorraine," and the two men proceeded to beat the victim about the head. Appellant used a pipe to strike the victim, causing severe injuries.
In count one of the information appellant was charged with assault with a deadly weapon in violation of section 245, subdivision (a)(1); intentional infliction of great bodily harm within the meaning of section 12022.7 and a prior serious felony conviction for robbery within the meaning of section *589 667. In count two he was charged with burglary and the same section 12022.7 and prior serious felony enhancements.
After a preliminary hearing, appellant entered into a plea bargain whereby he agreed to plead guilty to the assault charge and intentional infliction of great bodily injury, in exchange for which the burglary charge and prior serious felony enhancements would be dismissed. The sentence was not part of the plea bargain. Based upon the prosecutor's recommendation, the court dismissed count two and sentenced appellant to the upper term of four years for assault and a consecutive three-year sentence for intentional infliction of great bodily injury, for a total term of seven years. There was no statement setting forth reasons as required by section 1192.6, and it does not appear that any of the exceptions listed in section 1192.7 are present.

DISCUSSION
Appellant contends he has been prejudiced by the errors because he was not afforded a complete record for review nor an opportunity for review of prosecutorial abuse of the plea bargain procedure. Furthermore, appellant contends that had the court heard the prosecutor's rationale for the recommendation or considered whether the case fit one of the exceptions to the prohibition against plea bargains in serious felony offenses, the court may have imposed the mid or lower term of imprisonment instead of the upper term
While, as we will shortly explain, we do not reach the merits of appellant's contention, we note in passing that a similar argument was rejected by the court in People v. Cardoza (1984) 161 Cal. App.3d 40, 45, footnote 4 [207 Cal. Rptr. 388], where the court stated: "Defendant Cardoza asserts that `[i]t is entirely possible that the court would have imposed a lesser sentence than the prosecutor recommended, had the court known the prosecutor's specific reasons. It is entirely possible that a plea bargain more favorable to the defendant would have emerged had the prosecutor been required to state ... specific reasons in open court, on the record.' We do not view section 1192.6, subdivision (c), as a shield for defendants against hard bargaining prosecutors. Its purpose is to prevent the prosecutorial abuse of the plea bargaining procedure, i.e., plea bargains which are too lenient. Defendants are protected in plea bargaining because the law prohibits the imposition of punishment in excess of that which was bargained for by a defendant. (§[§] 1192.1, 1192.2, 1192.5.) Section 1192.5 provides, inter alia, that `the court may not proceed as to [a] plea other than as specified in the plea.' (Italics added.) We interpret this language to mean that the court lacks jurisdiction to alter the terms of a plea bargain so that it becomes more *590 favorable to a defendant unless, of course, the parties agree. (People v. Orin, supra, 13 Cal.3d 937, 942-943 [120 Cal. Rptr. 65, 533 P.2d 193].) Therefore, we reject defendant's argument that disclosure by the prosecutor could have resulted in a more favorable plea bargain or sentence." We agree with these observations. Appellant's contention indeed rests upon speculation and presents slim arguable merit.
(1) This language from Cardoza logically leads into a discussion of appellant's lack of standing to raise the issue of violation of sections 1192.6 and 1192.7. Cardoza traces the statutory history of this legislation and concludes that the provisions of section 1192.6 were intended by the Legislature to protect the public interest in vigorous prosecution of the accused, the imposition of appropriate punishment, the protection of the victims of crime, and to assure accountability by requiring public officials to disclose the basis of their actions. Thus, section 1192.6 was designed to benefit the public and not defendants. Similarly, we conclude that the Legislature in prohibiting plea bargains in serious felony cases under section 1192.7 clearly intended to protect the public and not defendants.
(2) Further, appellant did not raise the error in the trial court, thus giving the trial court an opportunity to correct it. A defendant is precluded from raising an error for the first time on appeal where there has been an opportunity to object to the error below and a defendant has failed to avail himself of the opportunity. (People v. Webb (1986) 186 Cal. App.3d 401, 410 [230 Cal. Rptr. 755]; People v. Johnson (1950) 99 Cal. App.2d 717, 731 [222 P.2d 335].)
(3) Lastly, appellant lacks standing because the trial court refused to issue to him a certificate of probable cause upon his application pursuant to section 1237.5.[4]
A defendant is precluded from attacking the validity of a plea bargain in the absence of a certificate of probable cause pursuant to section 1237.5. (People v. Ribero (1971) 4 Cal.3d 55, 62-64 [92 Cal. Rptr. 692, 480 P.2d 308]; see People v. Webb, supra, 186 Cal. App.3d 401, 410-412.) While appellant's argument is cast in terms of attacking the sentence, the merits of the argument necessarily are predicated upon finding the plea bargain was invalid because of failure to comply with section 1192.6 and/or section *591 1192.7. Whatever appellant's characterization, the substance and effect of the contention controls.
The judgment is affirmed.
Franson, J., and Martin, J., concurred.
NOTES
[1]  All statutory references are to the Penal Code unless otherwise indicated.
[2]  Section 1192.6 provides: "(a) In each felony case in which the charges contained in the original accusatory pleading are amended or dismissed, the record shall contain a statement explaining the reason for the amendment or dismissal.

"(b) In each felony case in which the prosecuting attorney seeks a dismissal of a charge in the complaint, indictment, or information, he or she shall state the specific reasons for the dismissal in open court, on the record.
"(c) When, upon a plea of guilty or nolo contendere to an accusatory pleading charging a felony, whether or not that plea is entered pursuant to Section 1192.5, the prosecuting attorney recommends what punishment the court should impose or how it should exercise any of the powers legally available to it, the prosecuting attorney shall state the specific reasons for the recommendation in open court, on the record. The reasons for the recommendation shall be transcribed and made part of the court file."
[3]  Section 1192.7 provided at the time of the offense in relevant part: "(a) Plea bargaining in any case in which the indictment or information charges any serious felony... is prohibited, unless there is insufficient evidence to prove the people's case, or testimony of a material witness cannot be obtained, or a reduction or dismissal would not result in a substantial change in sentence.

".... .... .... .... ....
"(c) ... `[S]erious felony' means any of the following:
"... (8) any other felony in which the defendant inflicts great bodily injury on any person, ..."
[4]  Section 1237.5 provides: "No appeal shall be taken by defendant from a judgment of conviction upon a plea of guilty or nolo contendere, or a revocation of probation following an admission of violation, except where:

"(a) The defendant has filed with the trial court a written statement, executed under oath or penalty of perjury showing reasonable constitutional, jurisdictional, or other grounds going to the legality of the proceedings; and
"(b) The trial court has executed and filed a certificate of probable cause for such appeal with the county clerk."
