
70 S.W.3d 848 (2002)
Sean Allen SMITH, Appellant,
v.
The STATE of Texas.
No. 1862-98.
Court of Criminal Appeals of Texas, En Banc.
March 13, 2002.
*849 William E. Kelly, III, Canyon, for Appellant.
James A. Farren, District Attorney, Canyon, Matthew Paul, State's Attorney, Austin, for State.
Before the Court en banc.
WOMACK, J., delivered the opinion of the Court, in which MEYERS, PRICE, JOHNSON, and HOLCOMB, JJ., joined.
The appellant and five other persons were charged with capital murder. Pursuant to an immunity agreement with the District Attorney, Randy Sherrod, the appellant gave a videotaped statement, submitted *850 to a polygraph examination, and offered testimony against his codefendants. Defense counsel drafted a motion to dismiss the charges against the appellant. At the hearing on the motion, Scott Morrison, an Assistant District Attorney, stated that the District Attorney's office joined the motion to dismiss. Based upon the joinder by the District Attorney, the trial court construed the motion to dismiss as a motion of the State and adopted the language of the defense in its dismissal order, stating "the Court finds that in the interests of justice and based upon the evidence, the motion should be granted." The charges against the appellant were dropped for over two years until a new District Attorney, James Farren, was elected and took office. After a review of the case, the new District Attorney decided to reopen the case against the appellant. The appellant filed an Amended Motion to Enforce the Agreement with the Prosecutor, which the trial court denied. After a trial in which the appellant pleaded not guilty, the jury assessed punishment at ten years, probated, and a $10,000 fine.
The appellant appealed his conviction, arguing that the trial court erred by refusing to enforce the immunity agreement and by not finding as a matter of law that the agreement barred the prosecution. The Court of Appeals affirmed the conviction, holding as a matter of law that the immunity agreement was not enforceable against the State because the trial court had not approved the agreement.[1] We granted discretionary review to address the issue of what is demanded by the requirement that the trial court "approve" an immunity agreement.
The State has suggested to us that the appellant violated the immunity agreement. This argument comes too late to be considered. The Court of Appeals' opinion did not mention, much less decide, such an issue. The grounds for review submitted by the appellant assume that there was an agreement between the appellant and the prosecutor to dismiss the charges with prejudice, and they assume that the appellant fulfilled his part of the bargain. The first ground for review asks whether a subsequent indictment for an offense arising from the transaction that was the subject of an immunity agreement could be brought solely because the order of dismissal did not state that the dismissal was "with prejudice." The second ground for review asks whether, after the appellant upheld his end of the bargain, the subsequent indictment could be brought solely because the trial court was unaware of the specific terms of the immunity agreement. The State neither responded to the petition nor cross-petitioned. We shall not address its argument for the first time on discretionary review.
The authority to grant immunity derives from the authority of a prosecutor to dismiss prosecutions.[2] The authority to dismiss a case is governed by Texas Code of Criminal Procedure article 32.02.[3] A *851 grant of immunity from prosecution is, conceptually, a prosecutorial promise to dismiss a case.[4] Article 32.02 directs that a dismissal made by the prosecutor must be approved by the trial court.[5] Therefore, a District Attorney has no authority to grant immunity without court approval,[6] for the approval of the court is "essential" to establish immunity.[7] In the appellant's case, the trial court approved the dismissal order, but did not signify that it approved the immunity agreement separately from its approval of the dismissal.
The appellant claims that the immunity agreement should be enforced under an equitable doctrine of substantial compliance with article 32.02. This equitable doctrine arguably underlies the cases on which the appellant relies, Camron v. State[8] and Ex parte Rusk.[9] In Camron, this court equitably enforced an immunity agreement that did not have the court's approval.[10] We have recently held, however, that the doctrine of equitable immunity does not exist in Texas.[11] We explained that the equitable rule used in Camron was abandoned seven years later, even though Camron was not expressly overruled.[12]
In Rusk the prosecutor gave his reasons for a dismissal orally instead of in writing as the statute requires. The Court upheld the dismissal on the equitable grounds that the State had substantially complied with the statute.[13]Rusk does not support the appellant's argument. The Court in Rusk did not sanction an equitable enforcement of an immunity agreement, but instead ordered the release of the defendant pursuant to a dismissal that the Court found substantially complied with the requirements of the statute. Nor did the Court attempt to find substantial compliance with the statute when the trial court did not approve of the dismissal, for it held, "It is manifest from a reading of the statute that the district attorney could not dismiss a case without the permission of the court."[14]
Neither of these cases addresses the level of judicial knowledge needed to comply with the requirement of article 32.02 that the trial court give its "permission" or "consent" when it approves a dismissal that results from an immunity agreement without expressly approving the underlying agreement. None of the cases mandating judicial approval of immunity agreements address the distinction between the approval of a dismissal and the approval of a promise to dismiss, nor do they elaborate *852 on the knowledge of an immunity agreement that a court might need to approve the agreement.[15]
The dissenting opinion says that if knowledge of the immunity agreement in this case is not required, then our opinion in Graham is "just `loose language' that does not accurately or precisely state the law concerning immunity."[16] With respect, we must point out the difference between Graham and this case. There was no dismissal in Graham. Graham was trying to enforce an immunity agreement that the trial court had not approved. We held that, because an immunity agreement is conceptually like a dismissal, it required judicial approval.[17] We did not say, nor were we called on to consider, whether the trial court must know and approve of the terms of the agreement. Graham did nothing more than make clear that the same requirement of approval that applies to a dismissal also applies to an immunity agreement that is made without any charges having been filed.
This appellant is trying to enforce a dismissal that the trial court has approved. The court in this case both knew of and approved the dismissal. A district court's knowledge and approval were the very things that were lacking in Graham. Graham cannot be read to require more. We must look elsewhere to decide what a trial court must know to validly approve a dismissal, whether it is based on an immunity agreement or anything else.
Article 32.02 requires the prosecutor to list in writing his reasons for dismissing a case, and the judgment of dismissal to incorporate those reasons.
The requirement of judicial approval of a dismissal is mandatory,[18] and the mandatory nature of that requirement is reflected in the text of Article 32.02. The second sentence of the statute repeats the requirement of judicial approval to the exclusion of the other requirements of the first sentence: "No case shall be dismissed without the consent of the presiding judge."
But the statement of reasons required by article 32.02 has been interpreted much differently than the requirement *853 of judicial approval.[19] We have held that the requirement of the statute to set out in writing the reasons for a dismissal is "directory" and not "mandatory," and substantial compliance therewith is sufficient. This is the reason why the dissent is incorrect when it assumes that Article 32.02 requires that a trial court know the reasons for dismissal to any particular degree.
In the instant case, the only reasons that the prosecutor gave for dismissing the case and the only reasons incorporated in the judgment of dismissal are that the case was dismissed "in the interests of justice." The phrase "in the interests of justice" could reflect the cognizance of the court as to the existence or terms of the appellant's immunity agreement, or it could simply reflect a deference to any rational basis that the prosecutor had to dismiss the prosecution.
It follows that if filing the statement of reasons is not mandated then neither would be the requirement that the judge incorporate those reasons into the order of dismissal. In the appellant's case, that the judge did not incorporate the terms of the immunity agreement into the order of dismissal does not render the immunity agreement unenforceable.
Similarly, that the order of dismissal did not state that the dismissal was "with prejudice" would not render the agreement unenforceable. Incorporation of the terms of the immunity agreement or a reference to the result of the agreement, dismissal with prejudice, would have the same effect. The effect would be that the dismissal order would reflect on its face that the prosecution was dismissed because of the immunity agreement. Although this would be a prudent and useful course,[20] it is not "the essence of the thing to be done, but [is] prescribed with a view of orderly conduct, the omission of which or if done in some other manner, would not prejudice the rights of any party."[21] The "required thing" of article 32.02 is that the prosecutor may dismiss a case for any reason that he or she deems sufficient subject only to the approval of the judge. Therefore a fulfilled immunity agreement is not rendered invalid solely because the order of dismissal did not state the dismissal was "with prejudice."
The dissent points out that a dismissal "with prejudice," which is more conclusive than a dismissal that is silent on the question, is required by a statute that requires charges to be brought within a stated time after arrest and by the Interstate Agreement on Detainers that requires detainers to be resolved within certain time limits.[22] The remedy for violations of these statutes is a bar on prosecution, and the statutory requirements reflect the statutorily mandated consequences. There is no similar, general requirement for other dismissals. *854 Whether a prudent defendant should insist on the judgment of dismissal's reciting its conclusiveness is another matter. In this case the appellant chose to accept the protection of the immunity agreement without the additional protection of a dismissal "with prejudice." His tactical or other reasons for doing so, and those of the State, do not appear, and we are not called on to evaluate them.
The question remaining is whether court awareness of the terms of an immunity agreement is required to make it enforceable. If the trial court must be aware of the terms of an immunity agreement, this precondition to an enforceable immunity agreement would come from the judge's responsibility to approve the dismissal.
When deciding what is demanded by the requirement that the trial court give its permission or consent to an immunity agreement, the roles of the prosecutor and the judge in dismissing cases must be compared. At common law, the prosecutor was given "practical control of all criminal proceedings," and the authority "to enter a nolle prosequi rest[ed] usually in the prosecuting attorney alone."[23] In 1876 the predecessor of article 32.02, article 577, modified the common-law rule that the prosecutor was the sole actor with the authority to dismiss a prosecution.[24] The authority of the Attorney General over criminal cases had been delegated to diffuse district attorneys, and the legislature feared that without supervision this arrangement might lead to abuse.[25]
This expansion of the court's role in dismissing cases was limited. The new statute did not authorize the courts either to set the conditions of a dismissal or to require that the prosecutor initiate a dismissal. We described the limited role of the court in respect to its new review authority over case dismissals: "The only enlargement of the power of the district court by the enactment of the statute of 1876 is to confer upon the court a veto power upon the action of the district attorney."[26]
Under the new statute, the prosecutor remained the controlling authority over dismissals subject only to the approval of the trial court. We described this new balance of authority over case dismissals, "The power of dismissal of a criminal cause rest[s] primarily in the initiative of the State's attorney, but also require[s] the consent of the presiding judge."[27] "The power of dealing with such agreements lies primarily with the prosecuting officer, and in Texas he may act with the consent of the court."[28] The prosecutor retained the power to assign the reasons that would justify a dismissal. A statement of reasons must be given, but no particular reasons are necessary; the State may "assign any reason which the court may deem *855 sufficient."[29] The degree to which a court requires knowledge of the reasons for dismissal to be written in the public records is a matter within the court's discretion, which may vary according to the requirements the court deems proper to impose on a particular prosecutor in a particular case.
To require that a trial court become familiar with the terms of every immunity agreement before approving the district attorney's request for a dismissal pursuant to the agreement would place the courts in a position of duplicating the work of the district attorney. The terms and conditions of an immunity agreement are wholly within the bargaining process of the parties involved in the contract, subject to the veto power of the court over their final agreement. Often the required level of performance under the agreement will be to the satisfaction of the prosecutor. We will not place the courts in a position that requires them to supervise the performance of every witness under an immunity agreement.
Supervision of the performance of an immunity agreement is the province of the prosecutor. In Ex parte Greenhaw,[30] we described the nature of an immunity agreement with the State:
Where two parties are indicted for murder, one of whom turns state's evidence, this forms and constitutes, under our law, a continuous contract, the good faith of which must be kept by both parties. Being a continuous contract, the terms and conditions are not consummated until the final trial of the party or parties accused against whom the accomplice agrees to testify.
A trial court could assess performance under an immunity agreement prior to dismissing a case, but the continuous nature of an immunity agreement would create institutional difficulties for a court in supervising performance under the contract after a dismissal. Although the courts must approve a dismissal that is the result of an immunity agreement, it is the prosecutor who is in the best position to evaluate performance before and after a dismissal.
Because it is the prosecutor who initiates a dismissal and sets the reasons for the dismissal, it is the prosecutor who is responsible for crafting the conditions of an immunity agreement. Provided the judge approves the dismissal that results from an immunity agreement, and is aware that the dismissal is pursuant to an immunity agreement, the judge does not have to be aware of the specific terms of that immunity agreement for it to be enforceable.
The Court of Appeals did not address the State's contention that the appellant failed to establish the existence of a mutual agreement. The court held that the agreement not to prosecute was unenforceable because the trial court did not approve the immunity agreement that motivated the prosecutor to agree not to prosecute. We have held this opinion to be in error, and we remand the case to the Court of Appeals to address the issues of the existence of, and performance under, the immunity agreement.
Reversed and remanded.
*856 JOHNSON, J., filed a concurring opinion.
COCHRAN, J., filed an opinion concurring in the judgment.
KELLER, P.J., filed a dissenting opinion, in which KEASLER and HERVEY, JJ., joined.
JOHNSON, J., filed a concurring opinion.
The opinion of the Court cites to Graham v. State, 994 S.W.2d 651 (Tex.Crim. App.1999), and again uses the terms "immunity agreement" and "agreement not to prosecute" interchangeably, one of the bases on which I differed with the majority in Graham. See id. at 657-658 (Johnson, J., concurring). I am unable to equate logically "a prosecutorial promise to dismiss a case" (ante at 851), with a prosecutorial promise not to file at all. However, this case is unlike Graham, in that criminal charges were filed and then dismissed with the approval of a judge and that both sides agreed at that time that there was an immunity agreement. I agree that once criminal charges are filed, whether by information or indictment, the approval of a judge is needed to dismiss them. I continue to believe that, until charges are filed, a dismissal of a complaint or a decision not to file formal charges rests within the sound discretion of the prosecutor and need not be ratified by a judge. With these comments, I join the opinion of the Court.
COCHRAN, J., delivered a concurring opinion.
This case demonstrates the wisdom of a rule that all immunity agreements must be in writing, signed by the defendant, his counsel, the prosecutor, and the trial judge. Indeed, the Legislature might consider enacting a statute outlining the procedures regulating the grant of transactional or use immunity. That said, I concur with the result reached by the majority in this particular instance, although I disagree with some of the reasoning. I conclude that, under these special circumstances, a defendant should not be made to suffer the disastrous consequences of a district attorney's inadvertent failure to inform the trial judge and to obtain his consent to what both original contracting parties agreed was a valid immunity agreement.

I.
The testimony taken during appellant's pretrial hearing on his Motion to Enforce Agreement with Prosecutor shows that, in 1990, appellant, along with five co-defendants, was indicted for the capital murder of Hilton Raymond Merriman. Early in his investigation of the burglary-murder, the Randall County District Attorney decided that he might need the cooperation and testimony of one of the defendants to prosecute the cases successfully.
Appellant's attorney and the district attorney, as well as an assistant district attorney, began lengthy negotiations concerning a possible immunity agreement with appellant. After almost two years, these negotiations culminated in an oral immunity agreement[1] and dismissal of the pending indictment against appellant. Appellant's attorney testified to the basic terms of the agreement: Appellant would *857 give a full interview to the district attorney's office, answer any questions the prosecutors might have, and "if they determined that [appellant's] answers were truthful and if he would agree to testify against any of the other Defendant's [sic] in the cases arising out of Mr. Merriman's death, that they would dismiss the case against him and would not seek to prosecute him on any further cases out of, and resulting from, the death of Mr. Merriman." The former district attorney and the prosecutor who dealt most with appellant during the de-briefing period both testified at the hearing and they confirmed that this was the essence of their agreement.
The appellant gave a full, videotaped interview to the primary prosecutor, in which he waived his Fifth Amendment right not to incriminate himself, even though he was then under indictment for capital murder. The primary prosecutor testified that he kept the videotape and continued to investigate to confirm or contradict the facts as stated by appellant. This confirmatory process took about ten months, at which point the prosecutor was satisfied that appellant had told the truth "as we could discern it," and the State had successfully tried one of the co-defendants for capital murder. Although appellant, as promised, kept himself available as a witness for his co-defendants' trials, the State did not request his testimony.
The district attorney and the primary prosecutor then agreed to dismiss the pending capital murder charges against appellant. It was their understanding that this dismissal would end any possible charges against appellant for his involvement in the Merriman burglary and murder.[2] The district attorney explicitly testified that he eventually agreed to the dismissal because appellant "had complied with all the terms of the agreement I had with" appellant's attorney. The district attorney made that decision after consulting with the primary prosecutor and the investigators, and determining that appellant's statement was consistent with "every piece of evidence" and lead that had been investigated. It was the district attorney's understanding that, with the dismissal of the charges, "[t]here was no question that [appellant's attorney] understood that if [appellant] was willing to do this [i.e., give the videotaped statement, cooperate with the prosecution, and testify if requested at the co-defendants' trials], and we had entered into that agreement, that no charges would be brought up again."
The district attorney told appellant's attorney to draft a dismissal motion. Appellant's attorney did so. That dismissal motion, *858 however, as drafted by appellant's attorney, said nothing about any immunity agreement. It merely recited that the charges were being dismissed "in the interests of justice and based upon the evidence." The trial court signed the dismissal motion. According to the district attorney, "I felt like the agreement was complete.... And once I signed the dismissal it was a done deal as far as I was concerned."
Approximately two years later a new district attorney reopened the investigation, apparently having decided that appellant had not been completely truthful in his videotaped statement and cooperation with the former prosecutors.[3] He found evidence that he said contradicted appellant's statement concerning his lack of involvement in the offense.[4] Therefore, he filed murder charges against appellant. After the trial court denied appellant's Motion to Enforce Agreement with the Prosecutor, the case went to trial. Appellant was convicted of murder and sentenced to ten years in prison, probated, and a $10,000 fine.
Appellant appealed, complaining that the trial court erred in refusing to enforce the immunity agreement. The court of appeals affirmed the conviction, holding that, as a matter of law, there was no binding immunity agreement because the trial court did not know or approve of it. Smith v. State, 979 S.W.2d 379 (Tex. App.Amarillo 1998). This Court granted review to decide whether an immunity agreement may be valid even if: 1) the dismissal order does not explicitly state that the indictment is dismissed "with prejudice"; or 2) the trial court is not aware of the specific terms of the agreement at the time he signs the dismissal order.[5]

II.
Appellant has been tried and convicted of murder for want of a written record of *859 the immunity agreement,[6] one duly signed by the district judge, that he and the former district attorney both agreed they made. The majority concludes that "it is the prosecutor who initiates a dismissal and sets the reasons for the dismissal, [thus] it is the prosecutor who is responsible for crafting the conditions of an immunity agreement." I agree wholeheartedly with this proposition. I respectfully disagree, however, with the subsequent proposition that "[p]rovided the judge approves the dismissal that results from an immunity agreement, the judge does not have to be aware of the specific terms of a fulfilled immunity agreement for it to be enforceable." This conclusion eviscerates the very rationale for requiring judicial knowledge and approval of immunity agreements.
Instead, I would conclude that in this particular (and highly unusual) case the State is now estopped from complaining that the immunity agreement to which it had agreed was invalid and unenforceable because it had failed to memorialize it and obtain the trial court's consent. I do not suggest that either the former or present district attorney were derelict in their duties, lacking in good faith, or acting less than honorably. Nonetheless, appellant is surely not at fault, and he ought not bear the severe consequences of the innocent mistakes of the State's representatives.
Like the dissent, I believe that a bright-line rulethe court must approve the immunity agreementis the right rule. The exchange of rights represented by immunity agreements is a serious matter, one which is best served by obtaining the trial court's written approval on the record. The written record, being immutable and accessible, protects those like appellant, and saves them from subsequent trials, hearings, and appeals simply to return to that place the written record should have shown they were in the first place: immunity ticket in pocket in return for the relinquishment of their valued Fifth Amendment right against self-incrimination.

III.
The Supreme Court has stated that: "[a]mong the necessary and most important of the powers of the States as well as the Federal Government to assure the effective functioning of government in an ordered society is the broad power to compel residents to testify in court or before grand juries or agencies."[7] This "power to compel testimony, and the corresponding duty to testify," are embedded in the Sixth Amendment.[8] "But the power to compel is not absolute," and is subject to "the Fifth Amendment privilege against compulsory self-incrimination."[9]
When these two rightssociety's need for a witness' testimony and that witness' right not to incriminate himselfcollide, the immunity doctrine comes to the rescue.[10] The government may compel the *860 witness to testify, but in return for his testimony, the State must offer immunity from prosecution or from any use of that evidence.[11]
Initially, Congress, the courts, and the states flip-flopped as to just what kind of immunity was required to substitute for the right against self-incrimination. Witnesses were alternatively granted the narrow "testimonial" immunity (immunity from in-court use of compelled testimony in subsequent criminal prosecution); the broad "transactional" immunity (immunity from prosecution for offenses to which compelled testimony relates); or the middle-of-the-road "use and derivative use" immunity (immunity from the use of the compelled testimony and any evidence derived therefrom). Under the federal constitution, a witness is entitled to at least "use and derivative use" immunity.[12]
In some jurisdictions, such as Texas, the trial court must endorse prosecutorial grants of immunity. The requirement that the trial court be involved may be made explicit by statute[13] or, as in Texas, by case law.[14] This requirement serves several valuable purposes. It memorializes the existence and terms of any immunity agreement. It ensures that a legally enforceable agreement is set out, not only for the benefit of the contracting parties, but for any court, other prosecutorial agency,[15] and other defendants or prospective defendants. *861 It ensures that the parties may measure performance against the explicit terms of the agreement. Most importantly for purposes of this appeal, it avoids later disputes over the existence and terms of the agreement when some of the parties change.
The trial court's role is very limited in this context. Immunity, after all, is the coin the government must pay to obtain the waiver of a person's right against self-incrimination and the information that he has about some crime. Thus, only the government can decide how much information it wants to "buy" and how much it is willing to pay for it in terms of either "use" or "transactional" immunity. The trial court's function is largely ministerial.[16] It simply memorializes the exchange in which a defendant or prospective defendant gives up his Fifth Amendment right in return for immunity. Ideally, the trial judge should approve the immunity agreement before, and not after, the defendant speaks. The dismissal of charges or filing of the nolle prosequi is simply the final event in a transactional immunity agreement, the acknowledgment that both parties have fulfilled their obligations under the agreement. There is no required litany language for the dismissal form itself, and it need not contain the phrase "with prejudice," although there may be much benefit to its inclusion.
It is true that occasionally equity will enforce a promise not to prosecute which was made without the trial court's knowledge and approval.[17] In those cases, it is the simple notion of fairnessthat a witness, having performed on his side, is entitled to specific performance from the prosecutorthat is appealed to.[18] Principles of fairness and public policy have also been *862 used to enforce such a promise made by a district attorney on that district attorney's successor.[19] Nevertheless, the general rule in Texas is that the courts must approve any formal grant of immunity. The reason behind the general rule was well stated by Judge Cardozo as he addressed a witness' refusal to testify despite the grant of a non-statutorily authorized promise of immunity:
The witness is within his privilege in insisting that the basis for his immunity shall be something more substantial than the grace or favor of the prosecutor who may bring him to the bar of justice.... To uphold a finding that his [the witness'] conduct amounted to a contempt it must appear that in refusing to answer he was violating a legal, and not merely a moral obligation. The immunity like the obligation must have its source and sanction in the law. An "equitable right to * * * clemency"a mere "gesture" of benevolenceis not a substitute for protection against indictment and conviction.[20]
Thus, by design, requiring the trial court to approve an immunity agreement protects *863 the prospective witness' Fifth Amendment rights. He cannot be compelled to testify against himself unless the trial court has ordered him to speak under a grant of immunity. Then he cannot refuse.
It seems illogical that a rule intended to protect a defendant's right against self-incrimination may then be used by the State as a sword against him. I would conclude that, in this particular case, the State is estopped from claiming that the immunity agreement that its representative, the then District Attorney of Randall County, entered into with appellant cannot be a valid immunity agreement because that district attorney failed to obtain the trial court's knowledgeable approval of the agreement.[21] It was the prosecution's responsibility to obtain the trial court's consent for its immunity agreement, and the defendant should not now be forced to bear the burden of the State's inadvertent failure to follow the required procedure.
I cannot join the majority opinion, although I agree with most of its reasoning. I believe that the majority's ultimate conclusion, that, if there is a dismissal, a trial court need not be aware of an immunity agreement's existence or content, will only lead to further confusion in this area of the law. Therefore, I concur in the court's judgment.
KELLER, P.J., filed a dissenting opinion in which KEASLER, and HERVEY, JJ., joined.
Appellant was indicted for capital murder. The State later moved for a dismissal of that indictment, and an order of dismissal was entered. Appellant was later indicted for murder. He filed with this Court a motion for leave to file an application for writ of mandamus, claiming that the prosecution violated an immunity agreement between appellant and the State. The trial judge filed a response. We denied appellant's motion for leave to file. The prosecution proceeded, and now appellant claims, on appeal, that the prosecution should have been dismissed due to an immunity agreement.
The order dismissing the capital murder prosecution does not cite an immunity agreement, nor does that order provide that the dismissal be with prejudice. Moreover, the trial court's response to appellant's motion for leave to file a writ of mandamus shows the following facts: (1) the trial court was unaware that the dismissal *864 was the result of any agreement between the defendant and the State, (2) the trial court never intended for the prosecution to be dismissed with prejudice, (3) the State's reason for dismissing the case was "the interests of justice" and the trial court's order of dismissal reflected that reason and only that reason, and (4) the trial court believed that the State was moving for dismissal because it had insufficient evidence to warrant a prosecution against appellant.
These facts raise the following questions: (1) can the State and the defendant, by agreement, turn a court-approved dismissal into a dismissal with prejudice when the trial court never intended that the dismissal be with prejudice, and (2) can the State and the defendant create an enforceable immunity agreement with a court-approved dismissal when the trial court is unaware of the existence of an immunity agreement at the time the dismissal occurs? I would answer both questions "no."
The "with prejudice" aspect of a dismissal is not simply a term of an immunity agreement. "With prejudice" describes the legal effect of the type of dismissal granted; it is a particular form of relief. Dismissals "with prejudice" and dismissals "without prejudice" are different forms of relief. There are occasions in which a dismissal with prejudice is required by statute.[1] It would be incongruous to hold that the State could effect a dismissal with prejudice by securing trial court approval of a dismissal without prejudice.
Moreover, the majority's reasoning in the present case conflicts with our decision in Graham v. State.[2] In Graham, we unequivocally stated that the trial court must approve the immunity agreement: "The trial judge correctly held that without approval of the court the district attorney had no authority to grant immunity from prosecution."[3] Several sentences later, we stated: "Because there was no judicial approval of the agreement in this case, the Hardin County prosecutor could not and did not bind his office to refrain from prosecuting [the defendant]."[4] Two sentences later, we stated: "But even though a prosecutor's agreement to transactional immunity is not, absent court approval, binding...."[5]
Is this language in Graham just "loose language" that does not accurately or precisely state the law concerning immunity? On the contrary, the language is in fact an accurate reflection of Graham's holding. Otherwise, the parties in Graham could have ratified the immunity agreement through a straw prosecution: Hardin County could have indicted the defendant, and the district attorney of Hardin County could have subsequently moved to dismiss the prosecution "in the interests of justice"without ever telling the trial court that the real reason for dismissal was an immunity agreement. The trial court, being unaware of the immunity deal and having no reason to believe that the dismissal was with prejudice, might then approve the dismissal. I fail to see what relationship an immunity agreement would have with the institution and subsequent *865 dismissal of proceedings where the trial court believes the dismissal is without prejudice. The parties would have simply created a sham transaction designed to legitimize the immunity agreementwith the trial court having no real involvement in approving the agreement. If such can be done, then Graham's holding makes no sense. If a trial court need not know that dismissal is based upon an immunity agreement (or at least that the dismissal is to be with prejudice), then why require trial court involvement in the absence of pending charges? Judge Johnson's approach in Graham[6] would be far more sensible: the immunity agreement would simply be a contract between the parties; trial court participation would be required only to dispense with a pending prosecution. If a prosecutor's power to enter a transactional immunity agreement really does stem from his power to dismiss a case, and trial court approval is a limitation upon that power, then trial court approval can be effective only if the trial court is aware that the dismissal is based upon an immunity agreement.
The majority contends that the trial court need not be aware of the terms of an immunity agreement for such an agreement to be effective. Otherwise, the majority reasons, the courts would be placed in the position of duplicating the work of the district attorney and of having to supervise the performance of every witness under an immunity agreement. It may be true that the trial court need not be aware of the details of an immunity agreement. But, the trial court should at least be aware that an immunity agreement exists upon which dismissal is requested. Or, barring that, the trial court should at least be made aware that the dismissal is to be with prejudice.
And I would agree with the majority that an immunity agreement would not be invalidated simply because the court's order contains no reference to the agreement or the words "with prejudice" are omitted. But, there should at least be evidence that the trial court knew the dismissal was to be with prejudice. The cases cited by the majority for the proposition that the written reasons requirement of Article 32.02 is "directory, not mandatory" do not hold that the trial court can be unaware of the true reasons for dismissal.[7]
I respectfully dissent.
NOTES
[1]  Smith v. State, 979 S.W.2d 379 (Tex.App.Amarillo 1998).
[2]  See Graham v. State, 994 S.W.2d 651, 653-54 (Tex.Cr.App.1999) (citing Zani v. State, 701 S.W.2d 249, 253 (Tex.Cr.App.1985)).
[3]  "The attorney representing the State may, by permission of the court, dismiss a criminal action at any time upon filing a written statement with the papers in the case setting out his reasons for such dismissal, which shall be incorporated in the judgment of dismissal. No case shall be dismissed without the consent of the presiding judge." TEX.CODE CRIM. PROC. art. 32.02. All further references to articles refer to the Code of Criminal Procedure.
[4]  Graham, 994 S.W.2d at 654.
[5]  See Tex.Code Crim. Proc. art. 32.02, supra note 3.
[6]  Wechsler v. State, 172 Tex.Crim. 559, 564, 361 S.W.2d 379, 383 (1962); Carlisle v. State, 138 Tex.Crim. 530, 532, 137 S.W.2d 782, 783 (1940).
[7]  Washburn v. State, 164 Tex.Crim. 448, 450, 299 S.W.2d 706, 707 (1956).
[8]  32 Tex.Crim. 180, 22 S.W. 682 (1893).
[9]  128 Tex.Crim. 135, 79 S.W.2d 865 (1935).
[10]  Camron, 32 Tex.Crim. at 180, 22 S.W. at 683.
[11]  See Graham, 994 S.W.2d at 656-57.
[12]  See id. at 656 (quoting Vincent v. State, 55 S.W. 819 (Tex.Cr.App.1900)).
[13]  Rusk, 128 Tex.Crim. at 137-38, 79 S.W.2d at 866.
[14]  Id. at 137, 79 S.W.2d at 866.
[15]  See Graham v. State, 994 S.W.2d 651, 654-56 (requiring only "the approval of the court"); Wechsler v. State, 172 Tex.Crim. 559, 564, 361 S.W.2d 379, 383 (1962) (requiring only the "approval" of the trial court); Washburn v. State, 164 Tex.Crim. 448, 450, 299 S.W.2d 706, 707 (1956) (same); Carlisle v. State, 138 Tex.Crim. 530, 532, 137 S.W.2d 782, 783 (1940) (same); Henderson v. State, 103 Tex.Crim. 502, 504, 281 S.W. 557, 558 (1926) (requiring court to have "ratified" the agreement); Dollar v. State, 92 Tex.Crim. 254, 256, 242 S.W. 733, 734 (1922) (requiring the "sanction" of the court); Messenger v. State, 81 Tex.Crim. 465, 467, 198 S.W. 330, 331 (1917) (holding that the court must have "sanctioned" the agreement and given its "agreement"); Ex parte Higgins, 71 Tex.Crim. 618, 619, 160 S.W. 696, 697 (1913) (inquiring whether the court had "sanctioned" and "approved" the agreement); Reagan v. State, 49 Tex.Crim. 443, 445, 93 S.W. 733, 734 (1906) (requiring only the "approval" of the court); Cox v. State, 69 S.W. 145, 147 (Tex.Cr.App. 1902) (requiring the "consent" of the court); Ex parte Gibson, 42 Tex.Crim. 653, 654, 62 S.W. 755, 755 (1901) (same); Vincent v. State, 55 S.W. 819, 820 (Tex.Cr.App.1900) (requiring the "approval" of the court); Nicks v. State, 40 Tex.Crim. 1, 4, 48 S.W. 186, 187 (1898) (requiring the "concurrence" and "consent" of the court).
[16]  Post at 850.
[17]  See supra at 851 (text accompanying notes 5-7).
[18]  See Graham, 994 S.W.2d at 654.
[19]  See Wallace v. State, 145 Tex.Crim. 625, 630, 170 S.W.2d 762, 764 (1943); Ex parte Kinsey, 152 Tex.Crim. 425, 427, 214 S.W.2d 628, 629 (1948) (holding that an oral motion by the State setting out the reasons for dismissal is sufficient to comply with the statute).
[20]  "It is always better, if not actually essential, that the court should make it a matter of record at the time that complete immunity was offered the witness by the prosecuting officer, with the sanction and approval of the court, and it even might be better for the offer of such immunity by the prosecuting officer to be in writing...." Higgins, 71 Tex.Crim. at 619, 160 S.W. at 697.
[21]  Rusk, 128 Tex.Crim. at 137, 79 S.W.2d at 866.
[22]  See post at 864-865.
[23]  See State v. Anderson, 119 Tex. 110, 115-19, 26 S.W.2d 174, 175-78 (1930) (detailing how firmly established at common law was the rule vesting the exclusive power in the prosecuting officer to dismiss a case).
[24]  Id. at 119-20, 26 S.W.2d at 178.
[25]  Id. at 120, 26 S.W.2d at 178.
[26]  Ibid., 26 S.W.2d at 178 (emphasis added).
[27]  Wallace, 145 Tex.Crim. at 629, 170 S.W.2d at 764.
[28]  Camron, 32 Tex.Crim. at 182, 22 S.W. at 682.
[29]  Rusk, 128 Tex.Crim. at 137, 79 S.W.2d at 866 (interpreting the predecessor of article 32.02).
[30]  41 Tex.Crim. 278, 281, 53 S.W. 1024, 1025 (1899). Accord Higgins, 71 Tex.Crim. at 619, 160 S.W. at 697.
[1]  Appellant's attorney testified that he had dealt with this district attorney for twenty years and that neither required the other to reduce agreements to writing. Although "handshake" agreements show commendable trust by the contracting parties, they are ill-advised in the context of legally binding immunity agreements.
[2]  The primary prosecutor testified that, with the dismissal of the charges, "I thought it was completely over for Sean Smith as far as anything to do with the Merriman homicide or burglary.... [T]here has to be an end to cases. And, in my opinion, once the case was dismissed, that was the final conclusion that the truth had been told, we had investigated as much as we could and that the case was over." When asked whether the oral immunity agreement was the equivalent of a contract, the prosecutor responded: "I think it has contractual aspects, and maybe, even a little bit above that. I think that a government official, when they give their word about what they will do, they're bound by that word." The district attorney testified similarly, stating "because at some point you have to have a closure, and sometimes you make decisions.... I mean we struggled with this for months to be sure we ran every possible lead down. But when the defense attorney makes a deal with you at some point where you need his [a defendant's] testimony, because you later don't need it, you can't back up on the deal. I don't know about anybody else; I can't. Youthere was no doubt in my mind or [appellant's attorney's] mind; once I signed that agreement [dismissal motion], it was over with."
[3]  The trial judge, concentrating upon the sole issue of whether a legally enforceable immunity agreement had ever existed, declined to allow the new district attorney to offer evidence on the issue of whether appellant had broken an otherwise valid immunity agreement.
[4]  At the hearing, the position of the new district attorney was not so much that appellant never had an immunity agreement, but that he had broken that agreement by giving a statement that was false. His not unreasonable position was that:

If the Defendant breached the contract, then the contract is broken. And again, we are prepared to present, in spite of the incredible evidence heard in this hearing, that the Defendant lied with impunity throughout the video tape. That he was active, voluntarily participating....
To suggest that the Defendant can bind the State to a promise, but breach his end of the agreement and lie with impunity, is to send a message to every defendant in this state and I guess in the world, that the key to success in criminal endeavors, is simply to make the prosecutor believe a lie, and then you are home free. There is nothing they can do to you.
[5]  This Court granted review of the following questions:

1) If a Defendant and the State enter into an agreement that an indictment returned against the Defendant will be dismissed with prejudice, and if the Defendant upholds his end of the bargain, can a subsequent indictment charging the same transaction be brought against the Defendant solely because the order of dismissal signed by the Court did not state the dismissal was with prejudice?
2) If a Defendant and the State enter into an agreement that an indictment returned against the Defendant will be dismissed with prejudice, and if the Defendant upholds his end of the bargain, can a subsequent indictment charging the same transaction be brought against the Defendant solely because the Court was not aware of the specific terms of the agreement not to prosecute?
[6]  One is reminded of the Mother Goose rhyme, "For want of a nail ... the kingdom was lost," in which the consequences were even more severe for want of a much more mundane item.
[7]  Murphy v. Waterfront Comm'n, 378 U.S. 52, 93-94, 84 S.Ct. 1594, 12 L.Ed.2d 678 (1964) (Justice White, concurring).
[8]  Kastigar v. United States, 406 U.S. 441, 444-45, 92 S.Ct. 1653, 32 L.Ed.2d 212 (1972).
[9]  Id. at 444, 92 S.Ct. 1653.
[10]  The first federal statute provided immunity to anyone testifying before either house of Congress for any fact or act upon which his testimony touched. See 11 Stat. 155-156 (1857). Much earlier, however, state immunity statutes were employed to prosecute consensual crimes that are otherwise difficult to detect without the testimony of persons involved in the crimes, such as gambling, bribery, dueling, and usury. Witt, Making the Fifth: The Constitutionalization of American Self-Incrimination Doctrine, 1791-1903, 77 Tex. L.Rev. 825, 846 (1999).
[11]  Murphy, 378 U.S. at 79, 84 S.Ct. 1594.
[12]  In 1892, the Supreme Court struck down a federal testimonial immunity statute as failing to provide immunity as broad as the Self Incrimination Clause required and ruled that the Fifth Amendment required "transactional" immunity. Counselman v. Hitchcock, 142 U.S. 547, 586, 12 S.Ct. 195, 35 L.Ed. 1110 (1892). That constitutional rule lasted until 1972, when the Supreme Court held that the newly enacted federal immunity statute, 18 U.S.C. §§ 6002, which required the in-between "use and derivative use" or "use plus use-fruits" immunity, satisfied the Fifth Amendment. Kastigar, 406 U.S. at 453, 92 S.Ct. 1653. Such immunity from use and derivative use is "coextensive with the privilege" and suffices to supplant it. This Court has agreed. See Ex Parte Shorthouse, 640 S.W.2d 924 (Tex.Crim.App.1982) (rejecting assertion that only absolute, complete, full or transactional immunity is permissible under Texas law; concluding that testimonial or use and derivative use immunity is constitutional); State v. Boyd, 38 S.W.3d 155 (Tex.Crim. App.2001). The privilege and immunity are like two coins with the same value, only one of which the witness may keep. Transactional immunity may still be granted, but it is not required by the United States Constitution. It is, in essence, an additional coin.
[13]  See e.g., 18 U.S.C. §§ 6002-6003.
[14]  See e.g., Bowden v. State, 1 Tex.App. 137 (1876); Vincent v. State, 55 S.W. 819, 820 (Tex.Crim.App.1900); Ex parte Gibson, 42 Tex.Crim. 653, 62 S.W. 755 (1901); Reagan v. State, 49 Tex.Crim. 443, 93 S.W. 733 (1906); Ex parte Higgins, 71 Tex.Crim. 618, 160 S.W. 696 (1913); Dollar v. State, 92 Tex.Crim. 254, 242 S.W. 733 (1922); Washburn v. State, 164 Tex.Crim. 448, 299 S.W.2d 706 (1956); Zani v. State, 701 S.W.2d 249 (Tex.Crim.App.1985); Graham v. State, 994 S.W.2d 651 (Tex.Crim. App.1999).
[15]  Once the immunity agreement is consummated, all other prosecutorial entitiesin Texas, the federal system, and other states must abide by it, at least to the extent of use immunity. In Murphy v. Waterfront Comm'n, 378 U.S. 52, 79, 84 S.Ct. 1594, 12 L.Ed.2d 678 (1964), the Supreme Court explained why that rulethat state and federal witnesses, compelled to testify in the face of the assertion of a privilege, must be granted both state and federal immunityis necessary. Most, if not all of the policies and purposes of the constitutional privilege against self-incrimination are defeated if a witness can be "whipsawed" into incriminating himself under both state and federal law but only one of them provides the witness immunity while the other is free to prosecute based upon his immunized testimony. Id. at 55-56, 84 S.Ct. 1594.
[16]  See United States v. Leyva, 513 F.2d 774, 776 (5th Cir.1975); In Re Grand Jury Investigation, 486 F.2d 1013, 1016 (3rd Cir.1973); In Re Perlin, 589 F.2d 260, 269 (7th Cir. 1978). As the Ninth Circuit explained in Urasaki v. United States Dist. Court, Cent. Dist., 504 F.2d 513, 514 (9th Cir.1974):

In passing upon an immunity application, the [federal district] court is confined to an examination of the application and the documents accompanying it for the purpose only of deciding whether or not the application meets the procedural and substantive requirements of the authorizing statute.
The question before the trial court is not the wisdom of the agreement, but the clarity and completeness of its terms.
[17]  See Robert M. Schoenhaus, Annotation, Prosecutor's Power to Grant Prosecution Witness Immunity From Prosecution, 4 A.L.R.4th 1221 (1981) (noting the differences between "some jurisdictionsTexas particularly which require the full participation of the courts before a grant of immunity will be deemed valid, and have denied legitimacy to the grants of immunity made by prosecutors acting without the courts' cooperation," and jurisdictions like California, "where equity has, in many circumstances, carried over to situations in which a prosecutor has acted without the court's knowledge or approval to secure testimony under the promised protection of immunity from prosecution.").
[18]  See e.g., Hardin v. State, 12 Tex.App. 186, 189 (1882):

If the State, through her officers, makes a solemn compact with her citizen, this contract should be enforced in the courts, in exact compliance with its terms. The agreement or contract (the defendant complying faithfully with his part) is in effect that the defendant should not be prosecuted. Upon what principle of justice is he driven from the court to his excellency the governor for an enforcement of this compact? We are of the opinion that common honesty and public justice demand that when such a contract is made and the party faithfully complies, as far as is within his power, the court in which the breach is attempted should interpose and prevent the breach by enforcing the contract, and should not drive the party out of the court to seek relief elsewhere.
See also Carlisle v. State, 138 Tex.Crim. 530, 137 S.W.2d 782 (1940) (holding that when district attorney promises use immunity to an accused in exchange for his testimony against a co-defendant, such an agreement is enforceable without regard to the general rule that no immunity may be extended without the approval of the court; when the prosecution makes a promise of immunity, it is obliged to respect the agreement); Camron v. State, 32 Tex.Crim. 180, 182, 22 S.W. 682, 682 (1893) ("If the State can make a contract with the defendant for immunity from prosecution for his offense, it is due to her own dignity that the contract be carried out in perfect faith" even though trial court had not approved agreement).
[19]  See State v. Hanson, 249 Ga. 739, 295 S.E.2d 297 (1982). The facts in Hanson are similar to those here. Hanson was arrested for possession and sale of methaqualone. In exchange for furnishing information concerning drug and gambling investigations, the district attorney gave Hanson a letter in which he purported to grant immunity from prosecution. The judge signed a postscript to the letter which noted that the letter had been called to his attention. At the same time, the district attorney dismissed the charges pending against Hanson. Although the dismissal was noted on the file, the notation gave no reason for the dismissal. The district attorney was later defeated in his bid for re-election, and the new district attorney re-indicted Hanson for possession and sale of methaqualone. Hanson's attorney filed a motion to quash the indictment, relying upon the letter from the former district attorney. There was no copy of this letter in the case file. The trial court denied the motion, and the Court of Appeals reversed, holding that the promises of the public prosecutor and the public faith pledged by him must be kept. Id. at 299. The Georgia Supreme Court affirmed, finding that the original promise was enforceable and binding on the district attorney's successor because "[t]he integrity of the office of the district attorney demands that promises made by the district attorney are binding on his successor to the extent that they are valid and enforceable." Id. at 302.
[20]  Doyle v. Hofstader, 257 N.Y. 244, 265-66, 177 N.E. 489, 497 (1931). Doyle was subpoenaed to a legislative committee investigating various New York City departments because "[t]here had been preliminary testimony from the lips of other witnesses that fees of extraordinary magnitude had been paid for his services [at the Board of Standards and Appeals] during a period of years." Id. at 249, 177 N.E. at 490. Doyle refused to answer questions concerning whether he had divided these fees with anyone else, in furtherance of a concerted plan of bribery and corruption, and whether he had paid any part of them as a bribe to any public officer. Id. Chief Justice Cardozo concluded that Doyle could not be compelled to answer potentially self-incriminatory questions without formal immunity or legislative amnesty.
[21]  It is a well-settled principle of law that a party cannot invite error and then complain of it. Ex parte Guerrero, 521 S.W.2d 613, 614 (Tex.Crim.App.1975). The rule applies when the party is the "moving factor" creating the error. Id. See also Capistran v. State, 759 S.W.2d 121, 124 (Tex.Crim.App.1982) (when a party invites error, he can not later complain of or attempt to gain an advantage based upon that error). Although the "invited error" doctrine is usually applied against the defendant, there is no logical or legal reason why the same doctrine ought not apply to the State in an appropriate circumstance. See, e.g., State v. Manning, 833 S.W.2d 322, 323 (Tex.App.Waco 1992, no pet.) (State could not complain on appeal about dismissal that it invited by making motion to dismiss). It is true, as Justice Holmes stated, that "[m]en must turn square corners when they deal with the Government." Rock Island, A. & L. R. Co. v. United States, 254 U.S. 141, 143, 41 S.Ct. 55, 65 L.Ed. 188 (1920). But, as Justice Jackson noted, "there is no reason why the square corners should constitute a one-way street." Federal Crop. Ins. Corp. v. Merrill, 332 U.S. 380, 387-88, 68 S.Ct. 1, 92 L.Ed. 10 (1947) (Jackson, J., dissenting). Here, when the original district attorney told appellant's attorney to draft the dismissal motion when it was the prosecutor's duty to memorialize the immunity agreement and obtain the consent of the trial court, he unintentionally invited the error that occurred.
[1]  See Texas Code of Criminal Procedure, Articles 28.061 (speedy trial) and 51.14 (Interstate Agreement on Detainers Act).
[2]  994 S.W.2d 651 (Tex.Crim.App.1999).
[3]  Id. at 656.
[4]  Id.
[5]  Id.
[6]  See id. at 657-658 (Johnson, J. concurring).
[7]  See Ex Parte Rusk, 128 Tex.Crim. 135, 79 S.W.2d 865, 866 (1935) (State's reasons given orally); Wallace v. State, 145 Tex.Crim. 625, 170 S.W.2d 762, 765 (1943) (State's written motion was not filed); Ex Parte Kinsey, 152 Tex.Crim. 425, 214 S.W.2d 628, 629 (1948) (opinion on rehearing) (defendant complained about the lack of a written statement).
