is guilty of a Class 2 felony.” Ill. Rev. Stat. 1979, ch. 56/2, par. 1401.
A defendant convicted of a Class X felony is required to be sentenced to a term of imprisonment of not less than 6 years nor more than 30 years (Ill. Rev. Stat. 1979, ch. 38, par. 1005 — 8—1(a)(3)), and cannot be given probation (Ill. Rev. Stat. 1979, ch. 38, par. 1005 — 5—3(c)(2)(C)).
We agree with petitioner that People ex rel. Carey v. Bentivenga (1981), 83 Ill. 2d 537, People ex rel. Hanrahan v. Wilson (1971), 48 Ill. 2d 30, and People ex rel. Ward v. Salter (1963), 28 Ill. 2d 612, leave no question that the sentencing provisions of the Unified Code of Corrections (Ill. Rev. Stat. 1979, ch. 38, par. 1001 — 1—1 et seq.) are mandatory and mandamus will lie to compel compliance with them. The situations here, however, are distinguishable in that in those cases the courts did not impose the proper sentences for the offenses of which the defendants were convicted. Here, although each of the defendants was charged with delivery of more than 30 grams of a substance containing cocaine, the respondents, after the presentation of evidence, made no finding of guilty on that charge. In each case the defendant was found guilty of the offense of delivery of less than 30 grams of a substance containing cocaine. It is a well-established principle of our jurisprudence that conviction of a lesser offense operates as an acquittal of a greater offense. (See, e.g., People v. Gray (1977), 69 Ill. 2d 44, 51; People v. Newman (1935), 360 Ill. 226, 232; People v. Carrico (1923), 310 Ill. 543, 545.) Thus, the effect of the judgment in each case was to acquit on the charge of delivery of more than 30 grams of a substance containing cocaine.
Initially, we observe that the 1970 Illinois Constitution prohibits appeals in criminal cases from a judgment of acquittal. (Ill. Const. 1970, art. VI, §6.) The People are precluded from taking an appeal, and we have repeatedly held that mandamus may not be employed as a substitute for a direct appeal. (See, e.g., Lara v. Schneider (1979), 75