有没有大神指点一下SQL语句错哪了?显示单行子查询返回多个行
deletefrombdc_cwhereljzid='2380';insertintobdc_c(cid,sjc,myc,xmid,zrzid,ljzid)select'...
delete from bdc_c where ljzid = '2380';
insert into bdc_c
(cid, sjc, myc, xmid, zrzid, ljzid)
select 'XC_' || cid CID,
sjc SJC,
sjc MYC,
xmid XMID,
zrzid ZRZID,
ljzid LJZID
from (select (select case
when max_cid is null then
0
else
max_cid
end
from (select max(to_number(replace(cid, 'XC_', ''))) max_cid
from bdc_c
where cid like 'XC_%')) + rownum cid,
sjc,
xmid,
zrzid,
ljzid
from (select sjc, xmid, zrzid, ljzid
from (select sjc, xmid, zrzid, ljzid
from bdc_h
where ljzid = '2380')
group by sjc, xmid, zrzid, ljzid
order by sjc));
update bdc_h h
set h.cid = (select c.cid
from bdc_c c
where h.sjc = c.sjc
and ljzid = '2380')
where ljzid = '2380'; 展开
insert into bdc_c
(cid, sjc, myc, xmid, zrzid, ljzid)
select 'XC_' || cid CID,
sjc SJC,
sjc MYC,
xmid XMID,
zrzid ZRZID,
ljzid LJZID
from (select (select case
when max_cid is null then
0
else
max_cid
end
from (select max(to_number(replace(cid, 'XC_', ''))) max_cid
from bdc_c
where cid like 'XC_%')) + rownum cid,
sjc,
xmid,
zrzid,
ljzid
from (select sjc, xmid, zrzid, ljzid
from (select sjc, xmid, zrzid, ljzid
from bdc_h
where ljzid = '2380')
group by sjc, xmid, zrzid, ljzid
order by sjc));
update bdc_h h
set h.cid = (select c.cid
from bdc_c c
where h.sjc = c.sjc
and ljzid = '2380')
where ljzid = '2380'; 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询