CREATE OR REPLACE PROCEDURE V8_UPD_FIXMAINTRIGHTS_DEL IS
BEGIN
  FOR mp IN (SELECT wusr_id
                  , wusr_value
                  , 'Hotel MaintenanceMaintenance Edit'||'@@' || whde_id ||'@@'|| wagr_id||'@@' || waty_id || '@@' ||'Delete' wusr_name
                  , wusr_xcms_id
                  , wusr_wegr_id
             FROM wusr
                , whde
                , wagr
                , waty
             WHERE wusr_name = 'Hotel MaintenanceMaintenance SearchView' AND whde_shortdesc = 'GEN' AND wagr_shortdesc = 'GEN' AND waty_wagr_id IS NOT NULL) LOOP
    INSERT INTO wusr (
                      wusr_id
                    , wusr_value
                    , wusr_name
                    , wusr_xcms_id
                    , wusr_wegr_id
                     )
    VALUES (
            seq_wusr.NEXTVAL
          , mp.wusr_value
          , mp.wusr_name
          , mp.wusr_xcms_id
          , mp.wusr_wegr_id
           );
           COMMIT;
  END LOOP;
EXCEPTION
  WHEN NO_DATA_FOUND THEN
    RAISE; --null;
  WHEN OTHERS THEN
    RAISE; --null;
END V8_UPD_FIXMAINTRIGHTS_DEL;
/

CREATE OR REPLACE PROCEDURE V8_UPD_FIXMAINTRIGHTS_EDIT IS
BEGIN
  FOR mp IN (SELECT wusr_id
                  , wusr_value
                  , 'Hotel MaintenanceMaintenance Edit'||'@@' || whde_id ||'@@'|| wagr_id||'@@' || waty_id || '@@' || 'Edit' wusr_name
                  , wusr_xcms_id
                  , wusr_wegr_id
             FROM wusr
                , whde
                , wagr
                , waty
             WHERE wusr_name = 'Hotel MaintenanceMaintenance SearchView' AND whde_shortdesc = 'GEN' AND wagr_shortdesc = 'GEN' AND waty_wagr_id IS NOT NULL) LOOP
    INSERT INTO wusr (
                      wusr_id
                    , wusr_value
                    , wusr_name
                    , wusr_xcms_id
                    , wusr_wegr_id
                     )
    VALUES (
            seq_wusr.NEXTVAL
          , mp.wusr_value
          , mp.wusr_name
          , mp.wusr_xcms_id
          , mp.wusr_wegr_id
           );
           COMMIT;
  END LOOP;
EXCEPTION
  WHEN NO_DATA_FOUND THEN
    RAISE; --null;
  WHEN OTHERS THEN
    RAISE; --null;
END V8_UPD_FIXMAINTRIGHTS_EDIT;
/

CREATE OR REPLACE PROCEDURE V8_UPD_FIXMAINTRIGHTS_RSLV IS
BEGIN
  FOR mp IN (SELECT wusr_id
                  , wusr_value
                  , 'Hotel MaintenanceMaintenance Edit'||'@@' || whde_id ||'@@'|| wagr_id||'@@' || waty_id || '@@' || 'Resolve' wusr_name
                  , wusr_xcms_id
                  , wusr_wegr_id
             FROM wusr
                , whde
                , wagr
                , waty
             WHERE wusr_name = 'Hotel MaintenanceMaintenance SearchView' AND whde_shortdesc = 'GEN' AND wagr_shortdesc = 'GEN' AND waty_wagr_id IS NOT NULL) LOOP
    INSERT INTO wusr (
                      wusr_id
                    , wusr_value
                    , wusr_name
                    , wusr_xcms_id
                    , wusr_wegr_id
                     )
    VALUES (
            seq_wusr.NEXTVAL
          , mp.wusr_value
          , mp.wusr_name
          , mp.wusr_xcms_id
          , mp.wusr_wegr_id
           );
           COMMIT;
  END LOOP;
EXCEPTION
  WHEN NO_DATA_FOUND THEN
    RAISE; --null;
  WHEN OTHERS THEN
    RAISE; --null;
END V8_UPD_FIXMAINTRIGHTS_RSLV;
/

CREATE OR REPLACE PROCEDURE V8_UPD_FIXMAINTRIGHTS_VIEW IS
BEGIN
  FOR mp IN (SELECT wusr_id
                  , wusr_value
                  , 'Hotel MaintenanceMaintenance Edit'||'@@' || whde_id ||'@@'|| wagr_id||'@@' || waty_id || '@@' || 'View' wusr_name
                  , wusr_xcms_id
                  , wusr_wegr_id
             FROM wusr
                , whde
                , wagr
                , waty
             WHERE wusr_name = 'Hotel MaintenanceMaintenance SearchView' AND whde_shortdesc = 'GEN' AND wagr_shortdesc = 'GEN' AND waty_wagr_id IS NOT NULL) LOOP
    INSERT INTO wusr (
                      wusr_id
                    , wusr_value
                    , wusr_name
                    , wusr_xcms_id
                    , wusr_wegr_id
                     )
    VALUES (
            seq_wusr.NEXTVAL
          , mp.wusr_value
          , mp.wusr_name
          , mp.wusr_xcms_id
          , mp.wusr_wegr_id
           );
           COMMIT;
  END LOOP;
EXCEPTION
  WHEN NO_DATA_FOUND THEN
    RAISE; --null;
  WHEN OTHERS THEN
    RAISE; --null;
END V8_UPD_FIXMAINTRIGHTS_VIEW;
/

CREATE OR REPLACE PROCEDURE V8_UPD_FIXMAINTRIGHTS_INS IS
BEGIN
  FOR mp IN (SELECT wusr_id
                  , wusr_value
                  , 'Hotel MaintenanceMaintenance Edit'||'@@' || whde_id ||'@@'|| wagr_id||'@@' || waty_id || '@@' || 'Insert' wusr_name
                  , wusr_xcms_id
                  , wusr_wegr_id
             FROM wusr
                , whde
                , wagr
                , waty
             WHERE wusr_name = 'Hotel MaintenanceMaintenance SearchView' AND whde_shortdesc = 'GEN' AND wagr_shortdesc = 'GEN' AND waty_wagr_id IS NOT NULL) LOOP
    INSERT INTO wusr (
                      wusr_id
                    , wusr_value
                    , wusr_name
                    , wusr_xcms_id
                    , wusr_wegr_id
                     )
    VALUES (
            seq_wusr.NEXTVAL
          , mp.wusr_value
          , mp.wusr_name
          , mp.wusr_xcms_id
          , mp.wusr_wegr_id
           );
           COMMIT;
  END LOOP;
EXCEPTION
  WHEN NO_DATA_FOUND THEN
    RAISE; --null;
  WHEN OTHERS THEN
    RAISE; --null;
END V8_UPD_FIXMAINTRIGHTS_INS;
/
