用事务实现多表同时删除数据

eg:三个表:T_DESIGN为主表,T_PROC_INST为中间表(外键为DESIGNE_ID与主表ID关联),T_PROC_FILE为存储文件表(外键表为PROC_INST_ID与T_PROC_INST表的主键ID关联)

 public bool DelData(decimal caseId)
        {
            ArrayList arr = new ArrayList();
            arr.Add("delete from T_PROC_FILE where PROC_INST_ID in (select ID from T_PROC_INST where DESIGNE_ID in         (select ID from T_DESIGN where ID='" + caseId + "'))");
            arr.Add("delete from T_PROC_INST where DESIGNE_ID in (select ID from T_DESIGN where ID='" + caseId + "')");
            arr.Add("delete from T_DESIGN where ID='" + caseId + "'");
            return GAEA.DATA.DBUtility.DbHelperOra.ExecuteSqlTran(arr);
        }

你可能感兴趣的:(用事务实现多表同时删除数据)