A person confined in a penitentiary or jail in the state may, by order of any court of record, be required to be produced for oral examination in the county where the person is imprisoned, and in a criminal case in any county in the state; but in all other cases the person's examination must be by a deposition.
Iowa Code § 622.82