


create procedure rf1 (in dir varchar, in nth int, in no_pk int := 0, in rb int := 0, in qp int := null)
{
  if (qp is not null)
    __dbf_set ('enable_qp', qp);
  insert into orders select * from orders_f table option (from sprintf ('%s/orders.tbl.u%d', dir, nth));
  if (no_pk)
    insert into lineitem index lineitem select * from lineitem_f table option (from sprintf ('%s/lineitem.tbl.u%d', dir, nth));
  else
    insert into lineitem select * from lineitem_f table option (from sprintf ('%s/lineitem.tbl.u%d', dir, nth));
  if (rb)
    rollback work;
  else
    commit work;
}


create procedure del_batch (in d_orderkey int)
{
  vectored;
  delete from lineitem where l_orderkey = d_orderkey;
  delete from orders where o_orderkey = d_orderkey;
  }

create procedure rf2 (in dir varchar, in nth int)
{
  declare cnt int;
  cnt := (select count (del_batch (d_orderkey)) from delete_f table option (from sprintf ('%s/delete.%d', dir, nth)));
  commit work;
  return cnt;
}
