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_bldr_wkr(
     Db_conn conn, Rndm_qry_tbl qry_tbl, Rndm_rng_tbl rng_tbl, Rndm_seq_tbl seq_tbl) {
   this.conn = conn;
   this.qry_tbl = qry_tbl;
   this.rng_tbl = rng_tbl;
   this.seq_tbl = seq_tbl;
   qry_idx_max = qry_tbl.Select_qry_max();
 }
 public void Exec_qry_end() {
   if (seq_in_qry == 0) return; // no sequences added
   qry_tbl.Insert(qry_idx, rng_idx, qry_itm.Qry_key(), qry_itm.Qry_data(), qry_itm.Qry_name());
 }