
270 N.W.2d 598 (1978)
STATE of Iowa, Appellee,
v.
Timothy S. LINT, Appellant.
No. 61254.
Supreme Court of Iowa.
October 18, 1978.
Robert W. Brinton of Archer, Johnson & Brinton, Clarion, for appellant.
Richard C. Turner, Atty. Gen., and Lee E. Poppen, County Atty., for appellee.
Considered by UHLENHOPP, P. J., and McCORMICK, ALLBEE, McGIVERIN and LARSON, JJ.
*599 McGIVERIN, Justice.
After being charged by county attorney's information, defendant Timothy S. Lint was convicted in a jury trial of robbery without aggravation. He appeals his conviction on the sole ground that trial court erred in refusing to set aside the information, which was filed after a convened grand jury had adjourned. Defendant was unindicted and incarcerated in the county jail at the time the grand jury was in session, but the grand jury did not inquire into his case. He alleges its failure to do so required the subsequently filed information to be set aside. We affirm the trial court.
I. Defendant was arrested on the robbery charge and placed in the Wright County jail on June 1, 1977. He was held to answer on June 17 and remained in jail due to failure to post bail bond. On July 8 a grand jury was impaneled. Based on inaccurate information, the county attorney at that time advised the court that no persons were imprisoned in the county jail on a criminal charge and not indicted. Later it was learned by the court that defendant was in jail and not indicted. Defendant and his counsel were given opportunity to challenge the grand jury panel and the individual grand jurors under sections 770.3 and 770.5, The Code, 1977. Defendant declined, stating those challenges could only be asserted before the grand jury was impaneled. The grand jury adjourned before July 15 without presentation of defendant's case to it. On July 15 a county attorney's information was filed charging defendant with robbery with aggravation.
Defendant then filed a motion to set aside the information alleging in substance that his rights under section 771.2(1), The Code, 1977, were violated in that he was unindicted and imprisoned in the county jail at a time while the grand jury was in session and the grand jury did not inquire into his case before being dismissed by the court.
The court overruled defendant's motion. The case proceeded to trial. At the close of the State's evidence and of all evidence, defendant renewed his pre-trial motion to set aside the information. The trial court again overruled his motion.
II. Defendant has no federal constitutional right to be indicted by a grand jury rather than being charged by county attorney's information. Furgison v. State, 217 N.W.2d 613, 616 (Iowa 1974); Nelson v. Bennett, 255 Iowa 773, 774, 123 N.W.2d 864, 865 (1963). Similarly there is no state constitutional right to a grand jury indictment. See Iowa Const., art. I, section 11 (1857, amended 1884). Therefore, defendant's claim must be based on Iowa statutes.
Sections 771.1 and 771.2(1), The Code, 1977, which were in effect at the times material here, state:
"771.1 Indictable Offenses. The grand jury shall inquire into all indictable offenses which may be tried within the county, and present them to the court by indictment.
"771.2 Special duties. It is made the special duty of the grand jury to inquire into:
1. The case of every person imprisoned in the jail of the county on a criminal charge and not indicted."
Similar duties for the grand jury appear in R.Cr.P. 3(4)(j)(1), section 813.2, 1977 Code, (Supp.1978), effective January 1, 1978.
Although the Code sets out various duties of the grand jury, not all statutory duties are mandatory. Some of the duties of the grand jury, set out in chapter 771, are not mandatory despite the statutory wording. The word "shall" in section 771.1 appears not to be mandatory when considered with section 769.2 which gives the county attorney the concurrent right to "file with the clerk of the district court, upon approval by a district judge . . . an information charging a person with an indictable offense." See State v. Allnutt, 158 N.W.2d 715, 717 (Iowa 1968). The information may be filed even while the grand jury is in session.
Section 771.2(1) must be read in conjunction with section 771.1. It is clear that all duties established with respect to the grand *600 jury are not mandatory in light of the necessary accommodation of section 771.1 to 769.2. It should be noted that section 771.2(1) uses less forceful language than section 771.1 in omitting the word "shall". Section 771.2(1) refers only to the "special duty . . . to inquire".
In Taylor v. Department of Transportation, 260 N.W.2d 521 (Iowa 1977), we reviewed the distinction between statutory duties that are mandatory and statutory duties that are directory. Duties are imposed in both mandatory and directory statutes; however, the consequence for failure to perform the duty differs. If the statutory duty "is essential to the main objective of the statute," the duty is mandatory and a failure to perform invalidates any action taken. If the statutory duty "is not essential to accomplishing the principal purpose of the statute", the duty is directory and a failure to perform is not invalidating absent prejudice. Id. at 522-523.
It does not appear section 771.2(1) was meant to impose a mandatory duty with an invalidating result. The intent of section 771.2(1) is to protect an accused from languishing in jail without a formal accusation ever being timely filed against him. 26 Drake L.Rev. 243, 293 (1977). The obvious remedy for an alleged unlawful detention of a defendant is habeas corpus relief. Preiser v. Rodriquiz, 411 U.S. 475, 484, 93 S.Ct. 1827, 1833, 36 L.Ed.2d 439, 447 (1973); State v. Henderson, 268 N.W.2d 173, 176 (Iowa 1978). Defendant was represented by counsel at the time the grand jury was in session in this case and the record does not reveal that any petition for such relief was filed.
That the legislature did not include a violation of section 771.2(1) as ground for setting aside an information is further evidence that such was not the intended result. To be valid, a motion to set aside an information must be made on one or more of the five grounds set forth in section 769.17, The Code, 1977. Defendant's contention is not based on any of those five grounds. Therefore, the sole basis raised in defendant's appeal to this court must fail. Cf. State v. Hall, 235 N.W.2d 702, 709-710 (Iowa 1975), appeal after remand, 249 N.W.2d 843 (Iowa), cert. denied, 434 U.S. 822, 98 S.Ct. 66, 54 L.Ed.2d 79 (1977).
Another jurisdiction that has considered the issue raised here by defendant is Oklahoma. Operating under a statute containing language similar to that in section 771.-2(1), the court in Pierro v. Turner, 95 Okl.Cr. 425, 247 P.2d 291, 295 (1952), held that even though the county attorney did not present an incarcerated defendant's case to the grand jury before it adjourned, the prosecution may proceed by filing an information on the same charge after the grand jury has been dismissed. The Pierro court noted it is the county attorney who, whether proceeding by indictment or information, must assemble the evidence and prepare the prosecution. The ability to proceed by information after grand jury adjournment allows the county attorney to proceed in the prosecution at the time he, in his professional judgment, believes best.
There is authority for the proposition that a county attorney may file an information on a case which the grand jury considered but on which it failed to return an indictment. United States v. Vaughn, 255 A.2d 483, 484 (D.C.App.1969); State v. Stone, 135 Fla. 816, 819, 185 So. 729, 730 (1939). If the county attorney may file an information regardless of the determination of the grand jury upon presentment of the case, a reversal for failure to have presented the case in the first place seems illogical.
We hold that the trial court was correct in overruling defendant's motion to set aside the information.
The case is
AFFIRMED.
