insert into menuauth (usertype,authname,menuno,isdel,) select max(usertype)+1,#authname#,1,0, from menuauth update menuauth set authname=#authname# where usertype=#usertype# delete a from menuauth a left outer join( select count(userno) usercnt,usertype from users where usertype = #usertype# group by usertype )b on b.usertype = a.usertype where a.usertype = #usertype# and (b.usercnt < 1 or b.usercnt is null); insert into menuauth (usertype,authname,menuno,isdel,cdt,cno,udt,uno,uip) select * from ( select #usertype# usertype,#authname# authname,1 menuno,0 isdel,now() cdt,#uno# cno,now() udt,#uno# uno,#uip# uip ) a where not exists( select usertype,authname,menuno from menuauth where usertype = #usertype# and menuno = 1 ); update menuauth a left outer join ( select count(userno) usercnt,usertype from users where usertype = #usertype# and status=1 group by usertype ) b on b.usertype = a.usertype set isdel=1 where a.usertype=#usertype# and (b.usercnt < 1 or b.usercnt is null); update menu a left outer join menu b on b.menuno=#menuorder# left outer join menu c on c.menuno=#pmenuno# set a.pmenuno=#pmenuno#, a.menuorder = ifnull(b.menuorder, -1) + 1, a.menulevel=c.menulevel + 1 , a.udt=, a.uno=#uno#, a.uip=#uip# where a.menuno=#menuno# update menu a left outer join (select menulevel from menu where menuno=#pmenuno#) b on 1 = 1 set udt=, uno=#uno#, uip=#uip# ,menuname=#menuname#, pmenuno=#pmenuno#, menuurl=ifnull(#menuurl#, ''),a.menulevel=b.menulevel + 1,menuorder=#menuorder#,isuse=#isuse#,ishid=#ishid# where a.menuno=#menuno#; insert into menu(menuname,pmenuno,menuurl,menulevel,menuorder,isuse,ishid,) select #menuname#,#pmenuno#,ifnull(#menuurl#,''),ifnull(c.menulevel, -1) + 1,#menuorder#,#isuse#,#ishid#, from (select #menuno# menuno) a left outer join menu b on b.menuno=a.menuno left outer join menu c on c.menuno=#pmenuno# where b.menuno is null select last_insert_id() delete from menuauth where menuno=#no#; delete from menu where menuno=#no# delete from menuauth where usertype=#usertype# and menuno not in ($menunos$); insert into menuauth (menuno, usertype,authname,isdel,) select a.menuno,#usertype#,#authname#,#isdel#, from menu a left outer join menuauth b on b.usertype=#usertype# and b.menuno=a.menuno where a.menuno in ($menunos$) and b.menuno is null INSERT INTO filegroup (tablename,columnname, ) VALUES (#tablename#, #columnname#, ) SELECT LAST_INSERT_ID() INSERT INTO fileinfo (fgno, orgname, fileurl, filesize, extension, dcount, isdel, ) values (#fgno#, #Files[].orgname#, #Files[].fileurl#, #Files[].filesize#, #Files[].extension#, 0, 0, ,#uno#,,#uno#,#uip#) update fileinfo set dcount = dcount + 1 where fileno=#fileno# update fileinfo set uip=#uip#, uno=#uno#, isdel=1 where fileno=#fileno# and (#isadmin# = 1 or #uno# = -999 or cno=#uno#) update fileinfo set uip=#uip#, uno=#uno#, isdel=1 where fgno=#fgno# and (#isadmin# = 1 or #uno# = -999 or cno=#uno#) insert into fileinfo (fgno,orgname,fileurl,filesize,extension,dcount,isdel,) select #nfgno#,a.orgname,concat(substr(a.fileurl,1,instr(a.fileurl,'.')-1),'_$copytype$_',#uno#,'_',#nfgno#, substr(a.fileurl,instr(a.fileurl,'.'))),filesize,extension,dcount,isdel, from fileinfo a where a.fgno=#ofgno# and a.isdel=0 insert into ncst (ntype,tcode,tname,) values (#ntype#,#ncscode#,#ncsname#,) update ncst set ,tcode=#ncscode#,tname=#ncsname# where ntno=#ncsno# insert into ncs$ndepthname$ (n$pndepthname$no,$ndepthname$code,$ndepthname$name,acode,) values (#pno#,#ncscode#,#ncsname#,#acode#,) update ncs$ndepthname$ set ,$ndepthname$code=#ncscode#,$ndepthname$name=#ncsname#,acode=#acode# where n$ndepthname$no=#ncsno# delete from ncs$ndepthname$ where n$ndepthname$no=#ncsno# delete from ncsu where nuno in ($nunos$); delete from ncsd where ndno in ($nunos$); delete from ncsb where nbno in ($nunos$); delete from ncsm where nmno in ($nunos$); delete from ncs$ndepthname$ where n$ndepthname$no=#ncsno#; insert into ncsu (ndno,ucode,acode,uname,) values $inquery$ insert into actlog (logtype,logtarget,userno,logdata,) values(#logtype#,#logtarget#,#userno#,#logdata#,) insert into authlog(logtype,userno,usertypeorg,usertypenew,) values(#logtype#,#userno#,#usertypeorg#,#usertypenew#,) insert into authlog(logtype,userno,usertypeorg,usertypenew,) select #logtype#,#userno#,a.usertype,#usertypenew#, from users a where a.userno=#userno# and a.usertype <> #usertypenew# update cmcalc a inner join ( select #Ds[].cmno# cmno,#Ds[].infee# infee,#Ds[].outfee# outfee,#Ds[].feeloc# feeloc,#Ds[].feebkpr# feebkpr,#Ds[].feebrt# feebrt,#Ds[].feemat# feemat,#Ds[].feefoo# feefoo,#Ds[].feeetc# feeetc,#Ds[].prtcnt# prtcnt ) b on b.cmno=a.cmno set a.feeloc =b.feeloc ,a.feebkpr =b.feebkpr ,a.feebrt =b.feebrt ,a.feemat =b.feemat ,a.feefoo =b.feefoo ,a.feeetc =b.feeetc ,a.prtcnt =b.prtcnt; insert into cmcalc (cmno,infee,outfee,feeloc,feebkpr,feebrt,feemat,feefoo,feeetc,prtcnt,) select a.cmno,a.infee,a.outfee,a.feeloc,a.feebkpr,a.feebrt,a.feemat,a.feefoo,a.feeetc,a.prtcnt, from ( select #Ds[].cmno# cmno,#Ds[].infee# infee,#Ds[].outfee# outfee,#Ds[].feeloc# feeloc,#Ds[].feebkpr# feebkpr,#Ds[].feebrt# feebrt,#Ds[].feemat# feemat,#Ds[].feefoo# feefoo,#Ds[].feeetc# feeetc,#Ds[].prtcnt# prtcnt ) a left outer join cmcalc b on b.cmno=a.cmno where b.cmno is null delete from ncsu where ndno in ( select d.ndno from ncst t inner join ncsm m on m.ntno=t.ntno inner join ncsb b on b.nmno=m.nmno inner join ncsd d on d.nbno=b.nbno where t.ntno=#ncsno# ); delete from ncsd where nbno in ( select b.nbno from ncst t inner join ncsm m on m.ntno=t.ntno inner join ncsb b on b.nmno=m.nmno where t.ntno=#ncsno# ); delete from ncsb where nmno in ( select m.nmno from ncst t inner join ncsm m on m.ntno=t.ntno where t.ntno=#ncsno# ); delete from ncsm where ntno=#ncsno#; delete from ncst where ntno=#ncsno# delete from ncsu where ndno in ( select d.ndno from ncsm m inner join ncsb b on b.nmno=m.nmno inner join ncsd d on d.nbno=b.nbno where m.nmno=#ncsno# ); delete from ncsd where nbno in ( select b.nbno from ncsm m inner join ncsb b on b.nmno=m.nmno where m.nmno=#ncsno# ); delete from ncsb where nmno=#ncsno#; delete from ncsm where nmno=#ncsno# delete from ncsu where ndno in ( select d.ndno from ncsb b inner join ncsd d on d.nbno=b.nbno where b.nbno=#ncsno# ); delete from ncsd where nbno=#ncsno#; delete from ncsb where nbno=#ncsno# delete from ncsu where ndno=#ncsno#; delete from ncsd where ndno=#ncsno# insert into kcblog (cdt,cp_cd,mobile,vssn,logmsg) values(now(),#cp_cd# ,case when #mobile# is not null then HEX(AES_ENCRYPT(#mobile#, )) else null end ,#vssn# ,#logmsg# ); INSERT INTO exceldownlog (userno, username, actiontime, position, comment, userip) VALUES ( #userno#, #username#, sysdate(), #position#, #comment#, #userip#);