select 'PG'||to_char(sysdate,'yyyy')|| LPAD(NVL(MAX(SUBSTR(pcode, 7, 4)) + 1, 1), 4, '0') from hb_np_project_baseinfo where pcode like 'PG'||to_char(sysdate,'yyyy')||'____'
此为最简单的方式了,比JAVA要快,既考虑到年,又考虑到编号,还有混合其它编号情况。一定要备忘一下。
select 'PG'||to_char(sysdate,'yyyy')|| LPAD(NVL(MAX(SUBSTR(pcode, 7, 4)) + 1, 1), 4, '0') from hb_np_project_baseinfo where pcode like 'PG'||to_char(sysdate,'yyyy')||'____'
此为最简单的方式了,比JAVA要快,既考虑到年,又考虑到编号,还有混合其它编号情况。一定要备忘一下。