|
|
@@ -6,6 +6,8 @@ declare
|
|
|
v_bgmbid number;
|
|
|
v_grtjid number;
|
|
|
v_grtjmxid number;
|
|
|
+ v_root_grtjid number;
|
|
|
+ v_root_grtjmxid number;
|
|
|
v_count number;
|
|
|
v_menu_count number;
|
|
|
c_name constant varchar2(64) := '星级文明班级评比总表';
|
|
|
@@ -95,6 +97,58 @@ begin
|
|
|
returning GRTJMXID into v_grtjmxid;
|
|
|
end if;
|
|
|
|
|
|
+ select count(*) into v_count
|
|
|
+ from GRTJ
|
|
|
+ where DXM='bj'
|
|
|
+ and GRTJMBID is null
|
|
|
+ and YYRYID is null
|
|
|
+ and GRTJLBM=51
|
|
|
+ and MC=c_name;
|
|
|
+ if v_count > 1 then
|
|
|
+ raise_application_error(-20004, 'root GRTJ duplicate');
|
|
|
+ elsif v_count = 1 then
|
|
|
+ select max(GRTJID) into v_root_grtjid
|
|
|
+ from GRTJ
|
|
|
+ where DXM='bj'
|
|
|
+ and GRTJMBID is null
|
|
|
+ and YYRYID is null
|
|
|
+ and GRTJLBM=51
|
|
|
+ and MC=c_name;
|
|
|
+ update GRTJ
|
|
|
+ set XH=1,KD=0,GD=0,JLZTM=51
|
|
|
+ where GRTJID=v_root_grtjid;
|
|
|
+ else
|
|
|
+ insert into GRTJ
|
|
|
+ (YYRYID,TJTLBM,GRTJMBID,YJTJZBM,MC,DXM,
|
|
|
+ XH,KD,GD,JLZTM,GRTJLBM)
|
|
|
+ values
|
|
|
+ (null,null,null,null,c_name,'bj',
|
|
|
+ 1,0,0,51,51)
|
|
|
+ returning GRTJID into v_root_grtjid;
|
|
|
+ end if;
|
|
|
+
|
|
|
+ select count(*) into v_count
|
|
|
+ from GRTJMX
|
|
|
+ where GRTJID=v_root_grtjid
|
|
|
+ and BGMBID=v_bgmbid;
|
|
|
+ if v_count > 1 then
|
|
|
+ raise_application_error(-20005, 'root GRTJMX duplicate');
|
|
|
+ elsif v_count = 1 then
|
|
|
+ select max(GRTJMXID) into v_root_grtjmxid
|
|
|
+ from GRTJMX
|
|
|
+ where GRTJID=v_root_grtjid
|
|
|
+ and BGMBID=v_bgmbid;
|
|
|
+ update GRTJMX
|
|
|
+ set MC=c_name,XH=1,JLZTM=51
|
|
|
+ where GRTJMXID=v_root_grtjmxid;
|
|
|
+ else
|
|
|
+ insert into GRTJMX
|
|
|
+ (GRTJID,TJZBM,SJGRTJMXID,MC,XH,JLZTM,BGMBID)
|
|
|
+ values
|
|
|
+ (v_root_grtjid,null,null,c_name,1,51,v_bgmbid)
|
|
|
+ returning GRTJMXID into v_root_grtjmxid;
|
|
|
+ end if;
|
|
|
+
|
|
|
delete from GRCD
|
|
|
where GRCDID in (1025936,1025937,1025938)
|
|
|
and DXM='ssnwjcStarClassSummary'
|
|
|
@@ -104,6 +158,8 @@ begin
|
|
|
dbms_output.put_line('BGMBID=' || v_bgmbid);
|
|
|
dbms_output.put_line('GRTJID=' || v_grtjid);
|
|
|
dbms_output.put_line('GRTJMXID=' || v_grtjmxid);
|
|
|
+ dbms_output.put_line('ROOT_GRTJID=' || v_root_grtjid);
|
|
|
+ dbms_output.put_line('ROOT_GRTJMXID=' || v_root_grtjmxid);
|
|
|
dbms_output.put_line('removed_legacy_menus=' || v_menu_count);
|
|
|
end;
|
|
|
/
|
|
|
@@ -116,7 +172,7 @@ select g.GRTJID,g.GRTJMBID,g.DXM,g.GRTJLBM,g.MC grtj_mc,m.GRTJMXID,
|
|
|
join GRTJMX m on m.GRTJID=g.GRTJID
|
|
|
join BGMB b on b.BGMBID=m.BGMBID
|
|
|
where g.DXM='bj'
|
|
|
- and g.GRTJMBID=5712
|
|
|
+ and (g.GRTJMBID=5712 or g.GRTJMBID is null)
|
|
|
and g.GRTJLBM=51
|
|
|
and b.BJM='ssnwjc_starClassSummary';
|
|
|
|