批量 删除 oracle sql传入list

列表的批量删除,案例使用前端ext框架,其他都可,具体代码如下:

----xml--------sql-------


 
 
delete from commonResourceConfig 


#ids[]#


   


---------------dao---------

public void  commonResourceConfigDelete(List ids)throws Exception{
this.getSqlMapClient().delete("commonResourceConfig_delete", ids);
}

-------------service-----------


public boolean commonResourceConfigDelete(List ids){
try {
getCommonResourceConfigDao().commonResourceConfigDelete(ids);
 return true;
} catch (Exception e) {
 e.printStackTrace();
 return false;
}
}


----------------action-------------------------


//删除列表,
public String deleteCommonResourceConfig(){
boolean flag  = false;
try{
String ids = Struts2Utils.getParameter("ids");
if(null != ids && ids.length() >0){
this.getCommonResourceConfigService().commonResourceConfigDelete(Arrays.asList(ids.split(",")));
}else {
throw new Exception("没有选择要删除的信息");
}
flag  = true;
}catch(Exception e){
flag  = false;
logger.error("删除失败 ", e);
}
Struts2Utils.renderJson(flag);
return null;

}


-----------------------jsp&js--------------------

注:ids获取的是列表的主键id,使用复选框,获取选中的id

{
text : '删除',
  xtype:"cirbutton",
   iconCls:"circle-delete",
handler : function() {
var ids = getCheckArrId("ckb");
if (ids.length > 0) {
  Ext.Msg.confirm('确认','确认删除选中的项??',function(btn){  
                   if('yes'==btn){  
                     Ext.Ajax.request({  
                        url:'commonResourceConfigAction!deleteCommonResourceConfig.do',
                        params :{ids:ids.join()},
                        success:function(flag){  
                       ds1.load({
            params:{
            start:0,
            limit:20
            }
            });
                       _alert('删除成功');  
                                },  
                        failure:function(flag){  
                       _alert('删除失败');  
                               }  
                        });  
          
                     }   
                     else{  
                     return false;  
                        } 
               });
}else{
_alert("请至少选择一列删除!");
}
}
}




本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部