(a) If a witness is a prisoner confined in a prison in the state, a state court may order the prisoner's temporary removal and production before a state court for the purpose of being orally examined
(1) by the court or a judge of the court in which the action or proceeding is pending, unless it is a district court;
(2) by a judge of the superior or supreme court when the action or proceeding is pending in a district court, or when the witness's oral examination is required before a judge or other persons out of court.
(b) In any other case, a state court may order the examination in prison upon a deposition.