--Update from 8_13_3_3 to 8_13_4_0

CREATE OR REPLACE PROCEDURE V8_UPD_GenderReportQueries IS
  V VARCHAR2(2000);
BEGIN
  FOR T IN (SELECT WRDQ_ID, WRDQ_QUERY FROM WRDQ) LOOP
    IF INSTR(T.WRDQ_QUERY,'decode(xcid_sex,1,''Male'',2,''Female'',3,''Unknown'',''Not defined''') > 0 THEN
      V := REPLACE(T.WRDQ_QUERY
                   ,'decode(xcid_sex,1,''Male'',2,''Female'',3,''Unknown'',''Not defined'''
                   ,'decode(xcid_sex,1,''Male'',2,''Female'',3,''Unknown'',4,''Divers'',5,''Transgender'',''Not defined''');
      UPDATE WRDQ SET WRDQ_QUERY = V WHERE WRDQ_ID = T.WRDQ_ID;
    END IF;
  END LOOP;
  FOR T IN (SELECT WRPQ_ID, WRPQ_QUERY FROM WRPQ) LOOP
    IF INSTR(T.WRPQ_QUERY,'decode(xcid_sex,1,''Male'',2,''Female'',3,''Unknown'',''Not defined''') > 0 THEN
      V := REPLACE(T.WRPQ_QUERY
                   ,'decode(xcid_sex,1,''Male'',2,''Female'',3,''Unknown'',''Not defined'''
                   ,'decode(xcid_sex,1,''Male'',2,''Female'',3,''Unknown'',4,''Divers'',5,''Transgender'',''Not defined''');
      UPDATE WRPQ SET WRPQ_QUERY = V WHERE WRPQ_ID = T.WRPQ_ID;
    END IF;
  END LOOP;
END;
/