A person confined in any prison in this state for any cause other than a sentence for felony may, by order of the court, be required to be produced for oral examination in the county where he is imprisoned. However, in all other cases his examination must be taken by deposition.