The district attorney shall receive written notice of, and shall have automatic standing and a legal interest in, any proceeding which may involve the release or nonadmission of county prisoners, delinquents or detainees due to the fact, duration or other conditions of custody. In addition to the district attorney's rights in such a proceeding, the district attorney may seek any equitable relief necessary to protect the district attorney's interest in the continued institutional custody and admission of county prisoners, delinquents or detainees.
18 Pa.C.S. § 1108