
142 Cal.App.3d 637 (1983)
191 Cal. Rptr. 361
STEPHEN TERRELL LEE, Petitioner,
v.
THE SUPERIOR COURT OF SAN DIEGO COUNTY, Respondent; THE PEOPLE, Real Party in Interest.
Docket No. 28544.
Court of Appeals of California, Fourth District, Division One.
April 27, 1983.
*638 COUNSEL
Tom Adler and Diane C. Campbell for Petitioner.
No appearance for Respondent.
John K. Van de Kamp, Attorney General, Steven V. Adler and Jay M. Bloom, Deputy Attorneys General, for Real Party in Interest.
*639 OPINION
BROWN (Gerald), P.J.
The petitioner, an attorney, is charged with solicitation for murder (Pen. Code, § 653f, subd. (b)) and conspiracy to commit murder (Pen. Code, § 182, subd. 1). In the middle of his first preliminary hearing, petitioner made a motion to continue on the ground he had just been successful in retaining counsel. The newly retained attorney was not in court that day, but had sent an associate to plead his cause and to tell the court he could put on the preliminary hearing in two weeks. The motion to continue was denied. Petitioner was bound over on both counts. Lee successfully challenged the denial of the motion to continue by a writ of mandate to this court. In granting the writ this court instructed the trial court "to vacate the order denying the Penal Code 995 motion ... [and] set aside the information...." Pursuant to our order the action was dismissed.
A new complaint was filed alleging the same two counts. At the conclusion of the second preliminary hearing, petitioner was held to answer on the solicitation charge. The magistrate found there was insufficient evidence to bind over on the conspiracy count.
On November 16, 1982, an information was filed charging solicitation and the twice-dismissed conspiracy count. Petitioner brought a motion to dismiss the conspiracy charge on the ground that an action which has been twice dismissed cannot then be prosecuted (Pen. Code, § 1387). The motion was denied. Petitioner sought a writ of mandate in this court which was likewise denied. A petition for hearing in the Supreme Court was granted and the matter was retransferred to this court with instructions to issue an alternative writ.
The question presented here is whether a dismissal pursuant to section 995, which was ordered on the ground of denial of counsel at the preliminary hearing, qualifies as an action "previously terminated" under Penal Code section 1387. That section states: "An order terminating an action pursuant to this chapter, or Section 859b, 861, 871, or 995, is a bar to any other prosecution for the same offense if it is a felony or it is a misdemeanor charged together with a felony and the action has been previously terminated pursuant to this chapter, or Section 859b, 861, 871, or 995, or if it is a misdemeanor not charged together with a felony, except in those felony cases, or those cases where a misdemeanor is charged with a felony, where subsequent to the dismissal of the felony or misdemeanor the judge or magistrate finds that substantial new evidence has been discovered by the prosecution which would not have been known through the exercise of due diligence at or prior to the time of termination of the action or that the termination of the action was the result of the direct intimidation of a material witness, as shown by a preponderance of the evidence.
*640 "However, if the previous termination was pursuant to Section 859b, 861, 871, or 995, the subsequent order terminating an action is not a bar to prosecution if either:
"(a) Good cause is shown why the preliminary examination was not held within 60 days from the date of arraignment or plea.
"(b) The motion pursuant to Section 995 was granted because of (1) present insanity of the defendant or (2) a lack of counsel after the defendant elected to represent himself or herself rather than being represented by appointed counsel."
(1) When a charge against a defendant has been dismissed twice on the merits for insufficiency of the evidence, further prosecution is prohibited (Ramos v. Superior Court (1982) 32 Cal.3d 26, 29 [184 Cal. Rptr. 622, 648 P.2d 589]). (2) At the other end of the spectrum, it is unclear whether a charge which is dismissed under Penal Code section 871, recharged in the information and dismissed under Penal Code section 995 is likewise barred (Ramos v. Superior Court, supra, p. 37, fn. 12). The People argue here and the trial court agreed that a dismissal does not terminate an action for purposes of this statute unless the dismissal is on the merits. However, a plain reading of the statute does not make any distinction as to the reason of the dismissal. The fact the exceptions to the operation of the statute deal with procedural rather than substantive questions leads to the inescapable conclusion that all dismissals, whether on the merits or for procedural deficiencies, are included.
The People argue under Ramos, refiling after two dismissals is not prohibited where the purpose of Penal Code section 1387 is not violated. The basic policy behind Penal Code section 1387 is to prevent the prosecution from harassing defendants or forum shopping for a judge who would rule in favor of the prosecution (Landrum v. Superior Court (1981) 30 Cal.3d 1, 14 [177 Cal. Rptr. 325, 634 P.2d 352]; People v. Peters (1978) 21 Cal.3d 749, 758-759 [147 Cal. Rptr. 646, 581 P.2d 651]). Here, say the People, these purposes are not violated because the first dismissal was sought by the petitioner, the dismissal was due to court error and it was ordered by the appellate court. However, the foregoing scenario is not unique to denial of counsel at the preliminary hearing; it will be repeated whenever there is a procedural ruling adverse to the defendant which is erroneous. We are presented with no reason why the particular procedural defect here should be treated differently from other procedural errors. It was a dismissal terminating an action.
The People suggest the second dismissal here also does not terminate an action under Penal Code section 1387 because, although a dismissal because of insufficient evidence, it occurred because certain evidence was excluded as *641 hearsay. (3) However, if the second dismissal was improper, the People should have appealed under Penal Code section 871.5, a course they elected not to take.
Let a writ of mandate issue ordering the Superior Court of San Diego County to vacate its order in case no. CRN 8061 denying the motion to dismiss under Penal Code section 1387 and to enter a new and different order granting the dismissal. The alternative writ is discharged.
Staniforth, J., and Butler, J., concurred.
The petition of real party in interest for a hearing by the Supreme Court was denied July 13, 1983.
