Whenever the Commonwealth or a defendant in a criminal prosecution in any circuit court in this Commonwealth requires as a witness in his behalf, an inmate in a state or local correctional facility as defined in § 53.1-1, the court, on the application of such defendant or his attorney, or the attorney for the Commonwealth, shall issue an order to the Director of the Department of Corrections to deliver such witness to the sheriff of the jurisdiction of the court issuing the order. If authorized by the court, the clerk of the circuit court or a deputy clerk may issue these orders on behalf of the court. The sheriff shall go where such witness may then be and carry him to the court to testify as such witness, and after he has testified and been released as such witness, carry him back to the place whence he came, for all of which service the sheriff shall be paid out of the criminal expense funds in the state treasury such compensation as the court in which the case is pending may certify to be reasonable.
Code 1950, § 8-300; 1966, c. 227; 1974, cc. 44, 45; 1977, c. 624; 2002, cc. 515, 544.