public void Exec_qry_bgn(Rndm_qry_itm qry_itm) {
    this.qry_itm = qry_itm;

    qry_idx = qry_tbl.Select_by_key(qry_itm.Qry_key());
    if (qry_idx == -1) qry_idx = ++qry_idx_max;
    else {
      // delete all
      qry_tbl.Delete_by_qry_idx(qry_idx);
      rng_tbl.Delete_by_qry_idx(qry_idx);
      seq_tbl.Delete_by_qry_idx(qry_idx);
    }

    rng_idx = seq_in_rng = seq_in_qry = 0;
    rng_stmt = rng_tbl.Insert_stmt();
    seq_stmt = seq_tbl.Insert_stmt();
  }
 public Rndm_rng_itm Exec_rng_end_or_null() {
   if (seq_in_rng == 0) return null; // no sequences added; return null;
   Rndm_rng_itm rv = new Rndm_rng_itm(qry_idx, rng_idx, rng_seq_bgn, seq_in_qry);
   rng_tbl.Insert(rng_stmt, qry_idx, rng_idx, rng_seq_bgn, seq_in_qry);
   return rv;
 }