//bug编号是否重复
select bug.bug_code,count(bug.bug_code) c from bug_record bug
group by bug.bug_code
having count(bug.bug_code)>1
//修改bug编号 sql拼
update bug_record bug set bug.bug_code=(
select '6-01_bug_' || to_char(to_number(substr(code,instr(code,'_')+1))+2) a from (
select substr(BUG_CODE,instr(BUG_CODE,'_')+1) code from Bug_Record where BUG_ID=(
select max(bug.BUG_ID) from Bug_Record bug where bug.BUG_CODE like '6-01_bug_%')
)
) where bug.bug_id='29079';
commit;
//生成bug编号
select ('24-01_bug_' || (select distinct case when (select count(1) from (
select to_char(to_number(substr(code,instr(code,'_')+1))+1) a from (
select substr(BUG_CODE,instr(BUG_CODE,'_')+1) code from Bug_Record where BUG_ID=(
select max(bug.BUG_ID)
from Bug_Record bug
where bug.BUG_CODE like '24-01_bug_%')
group by bug_code)
group by code))=0 then '1' else (
select to_char(to_number(substr(code,instr(code,'_')+1))+1) a from (
select substr(BUG_CODE,instr(BUG_CODE,'_')+1) code from Bug_Record where BUG_ID=(
select max(bug.BUG_ID)
from Bug_Record bug
where bug.BUG_CODE like '24-01_bug_%')
group by bug_code)
group by code) end as b from bug_record)) c from dual