On holding the defendant to answer, the magistrate shall take from each material witness examined by the magistrate on the part of the state a written undertaking, in the sum of two hundred fifty dollars ($250), to appear and testify, at the court at which the defendant is required to answer, on the second day of the term.