public int executeDelete(DeleteData data, Transaction tx) { Plan p = new TablePlan(data.tableName(), tx); p = new SelectPlan(p, data.pred()); UpdateScan us = (UpdateScan)p.open(); int count = 0; while (us.next()) { us.delete(); count++; } us.close(); return(count); }
public int executeModify(ModifyData data, Transaction tx) { Plan p = new TablePlan(data.tableName(), tx); p = new SelectPlan(p, data.pred()); UpdateScan us = (UpdateScan)p.open(); int count = 0; while (us.next()) { Constant val = data.newValue().evaluate(us); //返回此处的表达式的常量值 us.setVal(data.targetField(), val); //设置要更改字段处的值 count++; } us.close(); return(count); }
public int executeInsert(InsertData data, Transaction tx) { Plan p = new TablePlan(data.tableName(), tx); UpdateScan us = (UpdateScan)p.open(); us.insert(); string fldname; Constant val; for (int i = 0; i < data.fields().Count; i++) { fldname = data.fields()[i]; val = data.vals()[i]; us.setVal(fldname, val);//一对一,对应的设置 } us.close(); return(1); }
public void insert() { UpdateScan us = (UpdateScan)s; us.insert(); }
public RID getRid() { UpdateScan us = (UpdateScan)s; return(us.getRid()); }
public void delete() { UpdateScan us = (UpdateScan)s; us.delete(); }
public void setString(string fldname, string val) { UpdateScan us = (UpdateScan)s; us.setString(fldname, val); }
public void setInt(string fldname, int val) { UpdateScan us = (UpdateScan)s; us.setInt(fldname, val); }
//实现UpdateScan中所有接口 public void setVal(string fldname, Constant val) { UpdateScan us = (UpdateScan)s; us.setVal(fldname, val); }
public void moveToRid(RID rid) { UpdateScan us = (UpdateScan)s; us.moveToRid(rid); }