insert into term (tyear,tseq,rstime,retime,sstime,setime,gstime,getime,)
values (#tyear#,#tseq#,#rstime#,#retime#,#sstime#,#setime#,#gstime#,#getime#,)
update term set ,tyear =#tyear#,tseq =#tseq#,rstime=#rstime#,retime=#retime#,sstime=#sstime#,setime=#setime#,gstime=#gstime#,getime=#getime# where tmno=#tmno#
insert into cg (pcgno,cgname,cgcode,isuse,iscover,isdel,)
values (#pcgno#,#cgname#,#cgcode#,#isuse#,#iscover#,0,)
update cg set ,pcgno=#pcgno#,cgname=#cgname#,cgcode=#cgcode#,isuse=#isuse#,iscover=#iscover#,isdel=1,isuse=0
where cgno=#cgno#
insert into cm(ismaster,cgno,pcmno,cname,kname,tmno,classno,rstime,retime,sstime,setime,gstime,getime,cshape
,infee,outfee,accommofee,quota
,introhtml,targethtml,goalhtml,contenthtml,studyplace,studytime
,certcc,certgradecc,jobcc,jobpositiongrade,difficulty,isrefund,isuse,isdel,isseq,fgnocm,typeman,typeedu,typegrade,typejob,iscertificate,ischkatt,)
values (#ismaster#,#cgno#,#pcmno#,#cname#,#kname#,#tmno#,#classno#,#rstime#,#retime#,#sstime#,#setime#,#gstime#,#getime#,#cshape#
,#infee#,#outfee#,#accommofee#,#quota#
,#introhtml#,#targethtml#,#goalhtml#,#contenthtml#
,#studyplace#,#studytime#,#certcc#,#certgradecc#,#jobcc#,#jobpositiongrade#,#difficulty#,#isrefund#,#isuse#,0,#isseq#,#fgnocm#,#typeman#,#typeedu#,#typegrade#,#typejob#,#iscertificate#,#ischkatt#,);
SELECT LAST_INSERT_ID()
update cm set
,cgno =#cgno#
,pcmno =#pcmno#
,cname =#cname#
,kname =#kname#
,rstime =#rstime#
,retime =#retime#
,sstime =#sstime#
,setime =#setime#
,gstime =#gstime#
,getime =#getime#
,cshape =#cshape#
,infee =#infee#
,outfee =#outfee#
,accommofee =#accommofee#
,quota =#quota#
,introhtml =#introhtml#
,targethtml =#targethtml#
,goalhtml =#goalhtml#
,contenthtml =#contenthtml#
,studyplace =#studyplace#
,studytime =#studytime#
,certcc =#certcc#
,certgradecc =#certgradecc#
,jobcc =#jobcc#
,jobpositiongrade =#jobpositiongrade#
,difficulty =#difficulty#
,isrefund =#isrefund#
,isuse =#isuse#
,fgnocm =#fgnocm#
,typeman =#typeman#
,typeedu =#typeedu#
,typegrade =#typegrade#
,typejob =#typejob#
,iscertificate =#iscertificate#
,ischkatt =#ischkatt#
where cmno=#cmno#
delete from cmprof where cmno=#cmno# and userno not in($usernos$);
delete from cmbook where cmno=#cmno# and bkno not in($bknos$);
delete from cmrelay where cmno=#cmno# and ispre=1 and rcmno not in($rcmnospre$);
delete from cmrelay where cmno=#cmno# and ispre=0 and rcmno not in($rcmnosnext$);
delete from cmncsd where cmno=#cmno# and ndno not in($ndnos$);
insert into cmprof (cmno,userno,pfee,)
select #cmno#,a.userno,0,
from users a
left outer join cmprof b on b.cmno=#cmno# and b.userno=a.userno
where a.userno in ($usernos$) and b.userno is null;
insert into cmbook (cmno,bkno,)
select #cmno#,a.bkno,
from book a
left outer join cmbook b on b.cmno=#cmno# and b.bkno=a.bkno
where a.bkno in ($bknos$) and b.bkno is null;
insert into cmrelay (cmno,rcmno,ispre,)
select #cmno#,a.cmno,1,
from cm a
left outer join cmrelay b on b.cmno=#cmno# and b.ispre=1 and b.rcmno=a.cmno
where a.cmno in ($rcmnospre$) and b.cmno is null;
insert into cmrelay (cmno,rcmno,ispre,)
select #cmno#,a.cmno,0,
from cm a
left outer join cmrelay b on b.cmno=#cmno# and b.ispre=0 and b.rcmno=a.cmno
where a.cmno in ($rcmnosnext$) and b.cmno is null;
insert into cmncsd (cmno,ndno,)
select #cmno#,a.ndno,
from ncsd a
left outer join cmncsd b on b.cmno=#cmno# and b.ndno=a.ndno
where a.ndno in ($ndnos$) and b.cmno is null
update cminning a
inner join (
select a.cmino
from cminning a
left outer join cmprof b on b.cmno=a.cmno and a.userno=b.userno
where a.cmno=#cmno# and b.userno is null
) b on b.cmino=a.cmino
set a.userno=null
where a.cmno=#cmno#
update cm a
left outer join (select count(a.rcmno) cnt from cmrelay a where a.rcmno=#cmno#) b on 1 = 1
left outer join (select count(a.pcmno) cnt from cm a where a.pcmno=#cmno# and a.isdel=0) c on 1 = 1
left outer join (select count(a.cmno) cnt from ct a where a.cmno=#cmno# and a.isdel=0) d on 1 = 1
left outer join (select count(a.lectno) cnt from lect a where a.cmno=#cmno# and a.status < 5 and a.ischanged=0) e on 1 = 1
left outer join (select count(a.cmno) cnt from cmpc a where a.cmno=#cmno#) f on 1 = 1
set a.isdel=1,a.isuse=0,
where a.cmno=#cmno#a.cmno in ($cmnos$) and b.cnt+c.cnt+d.cnt+e.cnt+f.cnt < 1
delete from cminning where cmino = (
select a.cmino from (
select case when count(c.lectno) < 1 then #cmino# else 0 end cmino
from (select 1 col1) a
left outer join cminning b on b.cmino=#cmino#
left outer join lect c on c.cmno=b.cmno) a
)
delete from cminning where cmino = #cmino#
delete from cminning where cmino = (
select a.cmino from (
select case when count(b.cmino) < 1 then #cmino# else 0 end cmino
from (select 1 col1) a
left outer join cminningscd b on b.cmino=#cmino#) a
)
delete from cminningscd where cmisno = (
select a.cmisno from (
select case when count(c.lectno) < 1 then #cmisno# else 0 end cmisno
from (select 1 col1) a
left outer join cminningscd b on b.cmisno=#cmisno#
left outer join lect c on c.cmisno=b.cmisno and c.status=1 and c.ischanged=0
) a
)
update cm set isseq=#isseq#, where cmno=#cmno#
update cmprof a
inner join (
select #CMPRs[].cmno# cmno, #CMPRs[].pfee# pfee
) b on b.cmno=a.cmno
set a.pfee=b.pfee,
where a.userno=#userno#
insert into book(bkname,author,publisher,pubdate,fgnothumb,fgno,price,introhtml,contents,isuse,)
values (#bkname#,#author#,#publisher#,#pubdate#,#fgnothumb#,#fgno#,#price#,#introhtml#,#contents#,#isuse#,)
update book set
,bkname =#bkname#
,author =#author#
,publisher =#publisher#
,pubdate =#pubdate#
,fgnothumb =#fgnothumb#
,fgno =#fgno#
,price =#price#
,introhtml =#introhtml#
,contents =#contents#
,isuse =#isuse#
where bkno=#bkno#
delete from book
where not bkno in (
select distinct(a.bkno)
from cmbook a
) and bkno = #bkno#
delete from cminning where cmno=#cmno#;
insert into cminning (cmno,week,iseq,isonline,ititle,icontent,idate,iday,ist,iet,ctno,istaste,sttime,atime,mstime,metime,userno,)
select #cmno#,#Ds[].week#,#Ds[].iseq#,#Ds[].isonline#,#Ds[].ititle#,#Ds[].icontent#,#Ds[].idate#,#Ds[].iday#,#Ds[].ist#,#Ds[].iet#,#Ds[].ctno#,#Ds[].istaste#,#Ds[].sttime#,#Ds[].atime#,#Ds[].mstime#,#Ds[].metime#,#Ds[].userno#,now(),#uno#,now(),#uno#,#uip#
SELECT * FROM (SELECT LAST_INSERT_ID(0) col1) a WHERE col1 > 0;
insert into cminning (cmno,week,iseq,isonline,ititle,icontent,idate,iday,ist,iet,fgnotf,ctno,istaste,sttime,atime,mstime,metime,userno,)
select #cmno#,#week#,#iseq#,#isonline#,#ititle#,#icontent#,#idate#,#iday#,#ist#,#iet#,#fgnotf#,#ctno#,#istaste#,#sttime#,#atime#,#mstime#,#metime#,#userno#,
from (select 1 col1) a
left outer join cminning b on b.cmno=#cmno# and b.iseq=#iseq#
where b.cmino is null
SELECT last_insert_id()
SELECT * FROM (SELECT LAST_INSERT_ID(0) col1) a WHERE col1 > 0;
insert into cminningscd(cmino,estart,eend,quota,studyplace,)
values(#cmino#,#estart#,#eend#,#quota#,#studyplace#,)
SELECT last_insert_id()
update cminning a
left outer join (
select cmino, cmno from cminning where cmino <> #cmino# and cmno=#cmno# and iseq=#iseq#
) b on b.cmno=a.cmno
set
,week =#week#,iseq =#iseq#,isonline =#isonline#,ititle =#ititle#,icontent =#icontent#
,idate=#idate#,iday =#iday#,ist =#ist#,iet =#iet#,fgnotf=#fgnotf#
,ctno =#ctno#,istaste =#istaste#,sttime=#sttime#,atime =#atime#,mstime =#mstime#,metime =#metime#,userno =#userno#
where a.cmino=#cmino# and b.cmino is null
update cminningscd a
set ,cmino=#cmino#,estart=#estart#,eend=#eend#,quota=#quota#,studyplace=#studyplace#
where a.cmisno=#cmisno#
update cminning set istaste=0 where cmno=#cmno# and cmino <> #cmino#
insert into cmev (cmno,attend,attendcut,attendrfd,attendcutrfd,mid,midcut,midrfd,midcutrfd,final,finalcut,finalrfd,finalcutrfd,subject,subjectcut,subjectrfd,subjectcutrfd,discuss,discusscut,discussrfd,discusscutrfd,etc,etccut,etcrfd,etccutrfd,cut,cutrfd,isoffabs,)
select #cmno#,#attend#,#attendcut#,#attendrfd#,#attendcutrfd#,#mid#,#midcut#,#midrfd#,#midcutrfd#,#final#,#finalcut#,#finalrfd#,#finalcutrfd#,#subject#,#subjectcut#,#subjectrfd#,#subjectcutrfd#,#discuss#,#discusscut#,#discussrfd#,#discusscutrfd#,#etc#,#etccut#,#etcrfd#,#etccutrfd#,#cut#,#cutrfd#,#isoffabs#,
from (select 1 col1) a
left outer join cmev b on b.cmno=#cmno#
where b.cmno is null;
update cmev set
,attend =#attend#
,attendcut =#attendcut#
,attendrfd =#attendrfd#
,attendcutrfd =#attendcutrfd#
,mid =#mid#
,midcut =#midcut#
,midrfd =#midrfd#
,midcutrfd =#midcutrfd#
,final =#final#
,finalcut =#finalcut#
,finalrfd =#finalrfd#
,finalcutrfd =#finalcutrfd#
,subject =#subject#
,subjectcut =#subjectcut#
,subjectrfd =#subjectrfd#
,subjectcutrfd =#subjectcutrfd#
,discuss =#discuss#
,discusscut =#discusscut#
,discussrfd =#discussrfd#
,discusscutrfd =#discusscutrfd#
,etc =#etc#
,etccut =#etccut#
,etcrfd =#etcrfd#
,etccutrfd =#etccutrfd#
,cut =#cut#
,cutrfd =#cutrfd#
,isoffabs =#isoffabs#
where #cmno# > 0 and cmno=#cmno#
UPDATE cmex SET ,exname=#exname#,edesc=#edesc#,econdition=#econdition#,isblur=#isblur#,isusebackup=#isusebackup#
,isseq=#isseq#,isresultopen=#isresultopen#,etime=#etime#
where exno=#exno#
INSERT INTO cmex
(cmno,extype,exname,edesc,etime,econdition,evtype,eqtype,israndq,israndqi,qcount,isblur,tpoint,relaylimit,isusebackup,isseq,isresultopen,isdel,)
values (#cmno#,#extype#,#exname#,#edesc#,#etime#,#econdition#,#evtype#,#eqtype#,#israndq#,#israndqi#,#qcount#,#isblur#,#tpoint#,#relaylimit#,#isusebackup#,#isseq#,#isresultopen#,0,)
SELECT LAST_INSERT_ID()
update cmex set
,extype =#extype#
,exname =#exname#
,edesc =#edesc#
,etime =#etime#
,econdition =#econdition#
,evtype =#evtype#
,eqtype =#eqtype#
,israndq =#israndq#
,israndqi =#israndqi#
,qcount =#qcount#
,isblur =#isblur#
,tpoint =#tpoint#
,relaylimit =#relaylimit#
,isusebackup =#isusebackup#
,isseq =#isseq#
,isresultopen=#isresultopen#
where exno=#exno#
delete from cmexq where exno=#exno#
delete from cmexq where exno=#exno# and eqno not in ($eqnos$)
delete from cmexlayer where exno=#exno#
INSERT INTO cmexlayer(exno,qdiff,cc1,cc2,cc3,cc4,cc5,qcount,rpoint,)
values
(#exno#,#cmexlayers[].qdiff#,#cmexlayers[].cc1#,#cmexlayers[].cc2#,#cmexlayers[].cc3#,#cmexlayers[].cc4#,#cmexlayers[].cc5#,#cmexlayers[].qcount#,#cmexlayers[].rpoint#, now(), #uno#, now(), #uno#, #uip#)
INSERT INTO cmexq(exno,qseq,qno,rpoint,)
values
(#exno#,#cmexqs[].qseq#,#cmexqs[].qno#,#cmexqs[].rpoint#, now(), #uno#, now(), #uno#, #uip#)
update cmexq a
inner join (
select #cmexqs[].eqno# eqno, #cmexqs[].qseq# qseq, #cmexqs[].rpoint# rpoint
) b on b.eqno=a.eqno
set a.qseq=b.qseq, a.rpoint = b.rpoint, a.udt=now(), a.uno=#uno#, a.uip=#uip#
where a.exno=#exno#
update cmex set isdel=1 where exno=#exno#
update cmsd set isdel=1 where sdno=#sdno#
update cmrs set isdel=1 where rsno=#rsno#
INSERT INTO question (cmno, qdiff, cc1, cc2, cc3, cc4, cc5, isuse, atype, dpoint, qtext, qtextstring, qdesc, rightcount,ispassspace,isignorecase, )
values (#cmno#, #qdiff#, #cc1#, #cc2#, #cc3#, #cc4#, #cc5#, #isuse#, #atype#, #dpoint#, #qtext#, #qtextstring#, #qdesc#, #rightcount#,#ispassspace#,#isignorecase#, );
SELECT LAST_INSERT_ID()
INSERT INTO questionitem (qno, fgno, isright, qitext, isdel, )
values
(#qno#, #QIs[].fgno#, #QIs[].isright#, #QIs[].qitext#, 0, now(), #uno#, now(), #uno#, #uip#)
delete from questionitem where qno in (
select distinct qno
from (
select distinct a.qno
from question a
left outer join cmexq b on b.qno=a.qno
where a.qno in ($qnos$) and b.eqno is null
union all
select distinct a.qno
from question a
left outer join rscq b on b.qno=a.qno
where a.qno in ($qnos$) and b.rscqno is null
) a
);
delete from question where qno in (
select distinct qno from (
select distinct a.qno
from question a
left outer join cmexq b on b.qno=a.qno
where a.qno in ($qnos$) and b.eqno is null
union all
select distinct a.qno
from question a
left outer join rscq b on b.qno=a.qno
where a.qno in ($qnos$) and b.rscqno is null
) a
)
update question set isuse=#isuse# where qno in ($qnos$)
update question a
inner join questionitem b on b.qino=#qino# and b.qno=a.qno
set a.rightcount = a.rightcount - b.isright;
update questionitem set
,isdel=1
where qino=#qino#
UPDATE question SET
,cmno=#cmno#,qdiff=#qdiff#,cc1=#cc1#,cc2=#cc2#,cc3=#cc3#,cc4=#cc4#,cc5=#cc5#,isuse=#isuse#,dpoint=#dpoint#,qtext=#qtext#,qtextstring=#qtextstring#,qdesc=#qdesc#,rightcount=#rightcount#
,ispassspace=#ispassspace#,isignorecase=#isignorecase#
where qno=#qno#
UPDATE question SET
,cmno=#cmno#,isuse=#isuse#,qtext=#qtext#,qtextstring=#qtextstring#,qdesc=#qdesc#,rightcount=#rightcount#
where qno=#qno#
UPDATE questionitem SET
,fgno=#fgno#,isright=#isright#,qitext=#qitext#
where qino=#qino#
insert into cmsd(sdtype,cmno,sdname,sddesc,tpoint,sdcondition,fgno,isdel,)
values(#sdtype#,#cmno#,#sdname#,#sddesc#,#tpoint#,#sdcondition#,#fgno#,0,);
SELECT LAST_INSERT_ID()
update cmsd set
,sdtype =#sdtype#
,sdname =#sdname#
,sddesc =#sddesc#
,tpoint =#tpoint#
,sdcondition =#sdcondition#
,fgno =#fgno#
where sdno=#sdno#
update cmsd set
,sdname =#sdname#
,sddesc =#sddesc#
,tpoint =#tpoint#
,sdcondition =#sdcondition#
,fgno =#fgno#
where sdno=#sdno#
insert into cmrs(rstype,cmno,rsname,rscondition,rscno,isdel,)
values(#rstype#,#cmno#,#rsname#,#rscondition#,#rscno#,0,);
SELECT LAST_INSERT_ID()
update cmrs set
,rstype =#rstype#
,rsname =#rsname#
,rscondition =#rscondition#
,rscno =#rscno#
where rsno=#rsno#
update cmrs set
,rsname =#rsname#
,rscondition =#rscondition#
where rsno=#rsno#
insert into rsc(rstype,rscname,isuse,)
values(#rstype#,#rscname#,#isuse#,);
SELECT LAST_INSERT_ID()
update rsc set
,rstype =#rstype#
,rscname =#rscname#
,isuse =#isuse#
where rscno=#rscno#;
delete from rscq where rscno=#rscno# and qno not in ($QNosup$);
update rscq a
inner join (
select #Dsup[].rscqno# rscqno,#Dsup[].dseq# dseq
) b on b.rscqno=a.rscqno
set a.dseq=b.dseq,a.udt=now(),a.uno=#uno#,a.uip=#uip#
where a.rscno=#rscno#;
insert into rscq(rscno,qno,dseq,cdt,cno,udt,uno,uip)
values (#rscno#,#Dsin[].qno#,#Dsin[].dseq#,now(),#uno#,now(),#uno#,#uip#)
update rsc set
,rscname =#rscname#
,isuse =#isuse#
where rscno=#rscno#;
update rscq set
,dseq = #Dsup[].dseq#
where rscno=#rscno# and rscqno = #Dsup[].rscqno#;
insert into rscq(rscno,qno,dseq,)
values (#rscno#,#Ds[].qno#,#Ds[].dseq#,now(),#uno#,now(),#uno#,#uip#)
insert into cmev (cmno,attend,attendcut,attendrfd,attendcutrfd,mid,midcut,midrfd,midcutrfd,final,finalcut,finalrfd,finalcutrfd,subject,subjectcut,subjectrfd
,subjectcutrfd,discuss,discusscut,discussrfd,discusscutrfd,etc,etccut,etcrfd,etccutrfd,cut,cutrfd,)
values (#cmno#,100,100,100,100,0,0,0,0,0,0,0,0,0,0,0
,0,0,0,0,0,0,0,0,0,100,100,)
insert into cmmenu (cmno,isplan,iscontent,isev,isrs,isgrade,)
values(#cmno#,1,1,1,1,1,);
insert into cmmenubm (cmno,bmno,)
select #cmno#,a.bmno,
from boardmaster a
where a.bmposition=1 and a.isopen=1 and a.isdefault=1
update cmmenu set ,isplan=#isplan#,iscontent=#iscontent#,isev=#isev#,isrs=#isrs#,isgrade=#isgrade#
where cmno=#cmno#;
delete from cmmenubm where cmno=#cmno# and bmno not in ($bmnos$);
insert into cmmenubm (cmno,bmno,)
select #cmno#,a.bmno,
from boardmaster a
left outer join cmmenubm b on b.cmno=#cmno# and b.bmno=a.bmno
where a.bmno in ($bmnos$) and b.bmno is null;
insert into cm(ismaster,cgno,pcmno,cname,kname,tmno,classno,rstime,retime,sstime,setime,gstime,getime,cshape,typeman,typeedu,typegrade,typejob,infee,outfee,accommofee,quota,introhtml,targethtml,goalhtml,contenthtml,studyplace,studytime
,certcc,certgradecc,jobcc,jobpositiongrade,difficulty,isrefund,isuse,isseq,iscertificate,isdel,)
select #ismaster#,cgno,case when a.ismaster = 1 and #ismaster# = 0 then a.cmno else a.pcmno end,ifnull(#cname#, concat('사본_', cname)),a.kname,#tmno#
,case when #tmno# is null then null else ifnull(b.classno,0)+1 end
,t.rstime,date_format(t.retime,'%Y-%m-%d 23:59:59') retime
,t.sstime,date_format(t.setime,'%Y-%m-%d 23:59:59') setime
,t.gstime,date_format(t.getime,'%Y-%m-%d 23:59:59') getime
,a.cshape,a.typeman,a.typeedu,a.typegrade,a.typejob,infee,outfee,accommofee,quota,introhtml,targethtml,goalhtml,contenthtml,studyplace,studytime
,certcc,certgradecc,jobcc,jobpositiongrade,difficulty,isrefund,1,isseq,a.iscertificate,0,
from cm a
left outer join (
select max(b.classno) classno
from cm a
inner join cm b on b.ismaster=0 and b.pcmno=case when a.ismaster=1 then a.cmno else a.pcmno end and b.isdel=0 and b.tmno=ifnull(#tmno#,0)
where a.cmno=#orgcmno#
) b on b.classno is not null
left outer join term t on t.tmno=#tmno#
where a.cmno=#orgcmno#;
SELECT LAST_INSERT_ID()
insert into cmprof(cmno,userno,pfee,)
select #cmno#,a.userno,0,
from cmprof a
where a.cmno=#orgcmno#;
insert into cmbook(cmno,bkno,)
select #cmno#,a.bkno,
from cmbook a
where a.cmno=#orgcmno#;
insert into cmrelay(cmno,rcmno,ispre,)
select #cmno#,a.rcmno,a.ispre,
from cmrelay a
where a.cmno=#orgcmno#;
insert into cmncsd(cmno,ndno,)
select #cmno#,a.ndno,
from cmncsd a
where a.cmno=#orgcmno#;
insert into cminning(cmno,week,iseq,isonline,ititle,icontent,iday,idate,ist,iet,ctno,istaste,sttime,atime,mstime,metime,userno,orgcmino,)
select #cmno#,a.week,a.iseq,a.isonline,a.ititle,a.icontent,a.iday
,case when a.isonline=1 or b.sstime is null or a.iday is null then null else date_add(b.sstime, interval (a.iday - 1) day) end
,a.ist,a.iet,a.ctno,a.istaste,a.sttime,a.atime,a.mstime,a.metime,a.userno,cmino,
from cminning a
inner join cm b on b.cmno=#cmno#
where a.cmno=#orgcmno#;
insert into cminningscd(cmino,estart,eend,quota,)
select c.cmino,b.estart,b.eend,b.quota,
from cminning a
inner join cminningscd b on b.cmino=a.cmino
inner join cminning c on c.cmno=#cmno# and c.isonline=0
where a.cmno=#orgcmno# and a.isonline=0;
insert into cmev(cmno,attend,attendcut,attendrfd,attendcutrfd,mid,midcut,midrfd,midcutrfd,final,finalcut,finalrfd,finalcutrfd,subject,subjectcut,subjectrfd,subjectcutrfd
,discuss,discusscut,discussrfd,discusscutrfd,etc,etccut,etcrfd,etccutrfd,cut,cutrfd,isoffabs,)
select #cmno#,attend,attendcut,attendrfd,attendcutrfd,mid,midcut,midrfd,midcutrfd,final,finalcut,finalrfd,finalcutrfd,subject,subjectcut,subjectrfd,subjectcutrfd
,discuss,discusscut,discussrfd,discusscutrfd,etc,etccut,etcrfd,etccutrfd,cut,cutrfd,isoffabs,
from cmev a
where a.cmno=#orgcmno#;
insert into cmsd(sdtype,cmno,sdname,sddesc,tpoint,sdcondition,fgno,isdel,orgsdno,)
select sdtype,#cmno#,sdname,sddesc,tpoint,sdcondition,null,0,sdno,
from cmsd a
where a.cmno=#orgcmno# and a.isdel=0;
insert into cmrs(cmno,rscno,rstype,rsname,rscondition,isdel,)
select #cmno#,rscno,rstype,rsname,rscondition,0,
from cmrs a
where a.cmno=#orgcmno# and a.isdel=0;
insert into cmmenu(cmno,isplan,iscontent,isev,isrs,isgrade,)
select #cmno#,isplan,iscontent,isev,isrs,isgrade,
from cmmenu a
where a.cmno=#orgcmno#;
insert into cmmenubm(cmno,bmno,)
select #cmno#,a.bmno,
from cmmenubm a
where a.cmno=#orgcmno#
insert into cmex (cmno,extype,exname,edesc,etime,econdition,evtype,eqtype,israndq,israndqi,qcount,isblur,tpoint,relaylimit,isusebackup,isseq,isresultopen,isdel,)
select #cmno#,extype,exname,edesc,etime,econdition,evtype,eqtype,israndq,israndqi,qcount,isblur,tpoint,relaylimit,isusebackup,isseq,isresultopen,0,
from cmex a
where a.exno=#orgexno#;
SELECT LAST_INSERT_ID()
insert into cmexlayer(exno,qdiff,cc1,cc2,cc3,cc4,cc5,qcount,rpoint,)
select #exno#,qdiff,cc1,cc2,cc3,cc4,cc5,qcount,rpoint,
from cmexlayer a
where a.exno=#orgexno#;
insert into cmexq(exno,qseq,qno,rpoint,)
select #exno#,qseq,qno,rpoint,
from cmexq a
where a.exno=#orgexno#;
update cmsd set fgno=#fgno# where cmno=#cmno# and orgsdno=#orgsdno#
update cminning set fgnotf=#fgno# where cmno=#cmno# and orgcmino=#orgcmino#
update cm set fgnocm=#fgnocm# where cmno=#cmno#
insert into cm (ismaster,cgno,pcmno,cname,tmno,classno,rstime,retime,sstime,setime,gstime,getime,cshape,infee,outfee,quota,introhtml,targethtml,goalhtml,contenthtml,studyplace,studytime
,certcc,certgradecc,jobcc,jobpositiongrade,difficulty,isrefund,isuse,isseq,isdel,)
values (#ismaster#,#cgno#,null,#cname#,#tmno#,#classno#,#rstime#,#retime#,#sstime#,#setime#,#gstime#,#getime#,#cshape#,#infee#,#outfee#,#quota#,#introhtml#,#targethtml#,#goalhtml#,#contenthtml#,#studyplace#,#studytime#
,#certcc#,#certgradecc#,#jobcc#,#jobpositiongrade#,#difficulty#,#isrefund#,1,0,0,);
SELECT LAST_INSERT_ID()
update cm set
,cgno =#cgno#
,cname =#cname#
,sstime =#sstime#
,setime =#setime#
,introhtml =#introhtml#
where cmno=#cmno#
delete from cmpc where pcno=#cmno# and cmno not in ($cmnos$);
insert into cmpc(pcno,cmno,dseq,orginfee,orgoutfee,drate,infee,outfee,cdt,cno,udt,uno,uip)
values $inquery$;
update cmpc a
inner join (
select #Ds[].cmno# cmno, #Ds[].dseq# dseq, #Ds[].orginfee# orginfee,#Ds[].orgoutfee# orgoutfee,#Ds[].drate# drate,#Ds[].infee# infee,#Ds[].outfee# outfee
) b on b.cmno=a.cmno
set a.drate=b.drate,a.infee=b.infee,a.outfee=b.outfee,a.dseq=b.dseq
,udt=now(),uno=#uno#,uip=#uip#
where a.pcno=#cmno#;
update cm a
inner join (
select pcno cmno,sum(infee) infee,sum(outfee) outfee
from cmpc
where pcno=#cmno#
group by pcno
) b on b.cmno=a.cmno
set a.infee=b.infee,a.outfee=b.outfee
where a.cmno=#cmno#
INSERT INTO ct (cmno,qdiff,cc1,cc2,cc3,cc4,cc5,ctype,ccode,ccodedel,ctname,fgnothumb,fgnotf,tfurl,ismenu,isdel,isuse,isoversize,)
values (#cmno#,#qdiff#,#cc1#,#cc2#,#cc3#,#cc4#,#cc5#,#ctype#,#ccode#,#ccode#,#ctname#,#fgnothumb#,#fgnotf#,#tfurl#,#ismenu#,0,#isuse#,#isoversize#,);
SELECT LAST_INSERT_ID()
INSERT INTO ctpage (ctno,pseq,cpname,srcp,srcm,isdel,)
values
(#ctno#, #Ds[].pseq#, #Ds[].cpname#, #Ds[].srcp#,#Ds[].srcm#,0,now(),#uno#,now(),#uno#,#uip#)
update ctpage a
inner join (
select a.ctno,count(b.cmino) dcnt
from ct a
left outer join cminning b on b.ctno=a.ctno
where a.ctno=#ctno#
group by a.ctno
) b on b.ctno=a.ctno and b.dcnt = 0
set a.isdel=1,
where a.cpno=#cpno#
insert into ctpage (ctno,pseq,cpname,srcp,srcm,isdel,)
values $inquery$
update ct set
,cmno =#cmno#,qdiff =#qdiff#,cc1 =#cc1#,cc2 =#cc2#,cc3 =#cc3#,cc4 =#cc4#,cc5 =#cc5#,ctype =#ctype#
,ccode =#ccode#,ccodedel=#ccode#
,ctname=#ctname#,fgno =#fgno#,fgnotf=#fgnotf#,tfurl =#tfurl#,ismenu=#ismenu#,isuse=#isuse#
,fgnothumb=#fgnothumb#
,isoversize=#isoversize2#
where ctno=#ctno#
update ctpage a
inner join (
select #Ds[].cpno# cpno, #Ds[].pseq# pseq, #Ds[].cpname# cpname, #Ds[].srcp# srcp,#Ds[].srcm# srcm
) b on b.cpno=a.cpno
set ,a.pseq=b.pseq,a.cpname=b.cpname,a.srcp=b.srcp,a.srcm=b.srcm
where a.ctno=#ctno#
update ct a
inner join (
select a.ctno,count(b.cmino) dcnt
from ct a
left outer join cminning b on b.ctno=a.ctno
where a.ctno=#ctno#
group by a.ctno
) b on b.ctno=a.ctno and b.dcnt=0
set
,a.ccode=null,a.isdel=1
where b.dcnt=0 and a.ctno=#ctno#
update ct a
inner join (
select a.ctno,count(b.cmino) dcnt
from ct a
left outer join cminning b on b.ctno=a.ctno
where a.ctno in ($ctnos$)
group by a.ctno
) b on b.ctno=a.ctno and b.dcnt=0
set
,a.ccode=null,a.isdel=1
where b.dcnt=0 and a.ctno in ($ctnos$)
update cminning set fgno=#fgno# where cmino=#cmino#
SELECT * FROM (SELECT LAST_INSERT_ID(0) col1) a WHERE col1 > 0;
insert into pplog (
userno,cmno,isready,cgcode,cshape,typeman,typeedu,typegrade,typejob,cgno,cmisno,isrebate,rbankname,rbankacc,rbankowner,asname,brno,ceoname,post,address1,address2,btype,bkind,eino,mname
,mphone,taxemail,userpno,mobile,email,upost,uaddress1,uaddress2,isassignuser,uduty,slevel,isaccommodation,)
values (
#userno#,#cmno#,#isready#,#cgcode#,#cshape#,#typeman#,#typeedu#,#typegrade#,#typejob#,#cgno#,#cmisno#,#isrebate#,#rbankname#,#rbankacc#,#rbankowner#,#asname#,#brno#,#ceoname#,#post#,#address1#
,#address2#,#btype#,#bkind#,#eino#,#mname#
,HEX(AES_ENCRYPT(#mphone#, ))
,HEX(AES_ENCRYPT(#taxemail#, ))
,HEX(AES_ENCRYPT(#userpno#, ))
,HEX(AES_ENCRYPT(#mobile#, ))
,HEX(AES_ENCRYPT(#email#, ))
,#upost#,#uaddress1#,#uaddress2#,#isassignuser#,#uduty#,#slevel#,#isaccommodation#,)
SELECT LAST_INSERT_ID()
update assign set
,asname=#asname#
,ceoname=#ceoname#
,brno =#brno#
,post =#post#
,address1=#address1#
,address2=#address2#
,btype =#btype#
,bkind =#bkind#
,fgnobno=#fgnobno#
,eino=#eino#
,mname=#mname#
,mphone =case when #mphone# is not null then HEX(AES_ENCRYPT(#mphone#, )) else mphone end
,taxemail =case when #taxemail# is not null then HEX(AES_ENCRYPT(#taxemail#, )) else taxemail end
where asno=#asno#
update users set
,email =case when #email# is null and #email# > 80 then null when #email# is not null then HEX(AES_ENCRYPT(#email#, )) else email end
,mobile =HEX(AES_ENCRYPT(#mobile#, ))
,asno =#asno#
,userpno =case when #userpno# is not null then HEX(AES_ENCRYPT(#userpno#, )) else null end
,post =case when #post# is not null then #post# else post end
,address1 =case when #address1# is not null then #address1# else address1 end
,address2 =case when #address2# is not null then #address2# else address2 end
,uduty = #uduty#
,slevel = #slevel#
,isassignuser = #isassignuser#
where userno=#userno#
update lect set
,cmisno =case when #cmisno# is not null then #cmisno# else cmisno end
where lectno=#lectno#