資料庫qbs.qbs_dep_role如下,
引用的workid所在表qbs.qbs_work
現在想更新qbs_dep_role表下所有worklist中含有workid2和4列(對應業務意義為無這兩個工作區訪問許可權)
ibatis處理如下:
update qbs.qbs_dep_role as r ,(select e.worklist,e.deproleid ,k.workid from qbs.qbs_dep_role as e, qbs.qbs_work k where worklist like concat('%',k.workid,',%') and k.workid in
#) as w
set r.worklist = (select insert(w.worklist, locate(w.workid ,w.worklist), length(w.workid)+1, ''))
where r.deproleid = w.deproleid
解釋:(select e.worklist,e.deproleid ,k.workid from qbs.qbs_dep_role as e, qbs.qbs_work k where worklist like concat('%',k.workid,',%') ------ 臨時表中worklist中有workid(因為要刪除的工作區可能是多個,比如2和4,有的worklist中可能只有2,但冗餘會有workid 4)
and k.workid in -------workid是要刪除的
#) as w
set r.worklist = (select insert(w.worklist, locate(w.workid ,w.worklist), length(w.workid)+1, '')) 將原worklist替換為去掉workid的worklist
where r.deproleid = w.deproleid ----哪個部門的角色下的
更新字串列表中,指定位置的字串
if exists select from dbo.sysobjects where id object id n dbo f updatestr and xtype in n fn n if n tf drop function dbo f updatestr go 更新字串列表中,指定位置的字串...
更新字串列表中,指定位置的字串
if exists select from dbo.sysobjects where id object id n dbo f updatestr and xtype in n fn n if n tf drop function dbo f updatestr go 更新字串列表中,指定位置的字串...
更新字串列表中,指定位置的字串
if exists select from dbo.sysobjects where id object id n dbo f updatestr and xtype in n fn n if n tf drop function dbo f updatestr go 更新字串列表中,指定位置的字串...