[html]
#20121108 BY FMX
LET l_sql01 = " SELECT '[1]',qcgg02, tc_qcj031||tc_qcj03,tc_qcj04,tc_qcj032,TRIM(tc_qcj05) ,tc_qcj051,tc_qcj052,
WM_CONCAT(DECODE(QCGG04,'1', (CASE INSTR(qcgg06,'.',1,1) WHEN 1 THEN '0'||qcgg06 ELSE to_char(NVL(to_char(qcgg06),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'2', (CASE INSTR(qcgg06,'.',1,1) WHEN 1 THEN '0'||qcgg06 ELSE to_char(NVL(to_char(qcgg06),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'3', (CASE INSTR(qcgg06,'.',1,1) WHEN 1 THEN '0'||qcgg06 ELSE to_char(NVL(to_char(qcgg06),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'4', (CASE INSTR(qcgg06,'.',1,1) WHEN 1 THEN '0'||qcgg06 ELSE to_char(NVL(to_char(qcgg06),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'5', (CASE INSTR(qcgg06,'.',1,1) WHEN 1 THEN '0'||qcgg06 ELSE to_char(NVL(to_char(qcgg06),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'6', (CASE INSTR(qcgg06,'.',1,1) WHEN 1 THEN '0'||qcgg06 ELSE to_char(NVL(to_char(qcgg06),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'7', (CASE INSTR(qcgg06,'.',1,1) WHEN 1 THEN '0'||qcgg06 ELSE to_char(NVL(to_char(qcgg06),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'8', (CASE INSTR(qcgg06,'.',1,1) WHEN 1 THEN '0'||qcgg06 ELSE to_char(NVL(to_char(qcgg06),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'9', (CASE INSTR(qcgg06,'.',1,1) WHEN 1 THEN '0'||qcgg06 ELSE to_char(NVL(to_char(qcgg06),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'10',(CASE INSTR(qcgg06,'.',1,1) WHEN 1 THEN '0'||qcgg06 ELSE to_char(NVL(to_char(qcgg06),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'11',(CASE INSTR(qcgg06,'.',1,1) WHEN 1 THEN '0'||qcgg06 ELSE to_char(NVL(to_char(qcgg06),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'12',(CASE INSTR(qcgg06,'.',1,1) WHEN 1 THEN '0'||qcgg06 ELSE to_char(NVL(to_char(qcgg06),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'13',(CASE INSTR(qcgg06,'.',1,1) WHEN 1 THEN '0'||qcgg06 ELSE to_char(NVL(to_char(qcgg06),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'14',(CASE INSTR(qcgg06,'.',1,1) WHEN 1 THEN '0'||qcgg06 ELSE to_char(NVL(to_char(qcgg06),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'15',(CASE INSTR(qcgg06,'.',1,1) WHEN 1 THEN '0'||qcgg06 ELSE to_char(NVL(to_char(qcgg06),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'16',(CASE INSTR(qcgg06,'.',1,1) WHEN 1 THEN '0'||qcgg06 ELSE to_char(NVL(to_char(qcgg06),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'17',(CASE INSTR(qcgg06,'.',1,1) WHEN 1 THEN '0'||qcgg06 ELSE to_char(NVL(to_char(qcgg06),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'18',(CASE INSTR(qcgg06,'.',1,1) WHEN 1 THEN '0'||qcgg06 ELSE to_char(NVL(to_char(qcgg06),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'19',(CASE INSTR(qcgg06,'.',1,1) WHEN 1 THEN '0'||qcgg06 ELSE to_char(NVL(to_char(qcgg06),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'20',(CASE INSTR(qcgg06,'.',1,1) WHEN 1 THEN '0'||qcgg06 ELSE to_char(NVL(to_char(qcgg06),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END)))
FROM qci_file,qcgg_file,tc_qcj_file ",
" WHERE qcgg01 = '", g_argv3,"'",
" AND qci01 = qcgg01 AND qci00='1' ",
" AND qci02 = tc_qcj02 AND qci02=qcgg02 ",
" AND qci03 = qcgg03 AND qci03 ='",g_argv6,"'",
" AND qci041 = tc_qcj01 "
CASE
WHEN g_argv5 ='1' LET l_sql01 = l_sql01 CLIPPED," AND qcgg02 LIKE 'B%' "
WHEN g_argv5 ='2' LET l_sql01 = l_sql01 CLIPPED," AND qcgg02 LIKE 'C%' "
OTHERWISE
LET l_sql01 = l_sql01
END CASE
LET l_sql01 = l_sql01 CLIPPED," GROUP BY qcgg02,tc_qcj031,tc_qcj03,tc_qcj032,tc_qcj04,tc_qcj05,tc_qcj051,tc_qcj052 "
LET l_sql02=" SELECT '[2]',qcgg02, tc_qcj031||tc_qcj03,tc_qcj04,tc_qcj032,TRIM(tc_qcj05) ,tc_qcj051,tc_qcj052,
WM_CONCAT(DECODE(QCGG04,'1', (CASE INSTR(qcgg061,'.',1,1) WHEN 1 THEN '0'||qcgg061 ELSE to_char(NVL(to_char(qcgg061),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'2', (CASE INSTR(qcgg061,'.',1,1) WHEN 1 THEN '0'||qcgg061 ELSE to_char(NVL(to_char(qcgg061),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'3', (CASE INSTR(qcgg061,'.',1,1) WHEN 1 THEN '0'||qcgg061 ELSE to_char(NVL(to_char(qcgg061),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'4', (CASE INSTR(qcgg061,'.',1,1) WHEN 1 THEN '0'||qcgg061 ELSE to_char(NVL(to_char(qcgg061),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'5', (CASE INSTR(qcgg061,'.',1,1) WHEN 1 THEN '0'||qcgg061 ELSE to_char(NVL(to_char(qcgg061),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'6', (CASE INSTR(qcgg061,'.',1,1) WHEN 1 THEN '0'||qcgg061 ELSE to_char(NVL(to_char(qcgg061),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'7', (CASE INSTR(qcgg061,'.',1,1) WHEN 1 THEN '0'||qcgg061 ELSE to_char(NVL(to_char(qcgg061),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'8', (CASE INSTR(qcgg061,'.',1,1) WHEN 1 THEN '0'||qcgg061 ELSE to_char(NVL(to_char(qcgg061),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'9', (CASE INSTR(qcgg061,'.',1,1) WHEN 1 THEN '0'||qcgg061 ELSE to_char(NVL(to_char(qcgg061),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'10',(CASE INSTR(qcgg061,'.',1,1) WHEN 1 THEN '0'||qcgg061 ELSE to_char(NVL(to_char(qcgg061),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'11',(CASE INSTR(qcgg061,'.',1,1) WHEN 1 THEN '0'||qcgg061 ELSE to_char(NVL(to_char(qcgg061),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'12',(CASE INSTR(qcgg061,'.',1,1) WHEN 1 THEN '0'||qcgg061 ELSE to_char(NVL(to_char(qcgg061),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'13',(CASE INSTR(qcgg061,'.',1,1) WHEN 1 THEN '0'||qcgg061 ELSE to_char(NVL(to_char(qcgg061),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'14',(CASE INSTR(qcgg061,'.',1,1) WHEN 1 THEN '0'||qcgg061 ELSE to_char(NVL(to_char(qcgg061),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'15',(CASE INSTR(qcgg061,'.',1,1) WHEN 1 THEN '0'||qcgg061 ELSE to_char(NVL(to_char(qcgg061),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'16',(CASE INSTR(qcgg061,'.',1,1) WHEN 1 THEN '0'||qcgg061 ELSE to_char(NVL(to_char(qcgg061),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'17',(CASE INSTR(qcgg061,'.',1,1) WHEN 1 THEN '0'||qcgg061 ELSE to_char(NVL(to_char(qcgg061),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'18',(CASE INSTR(qcgg061,'.',1,1) WHEN 1 THEN '0'||qcgg061 ELSE to_char(NVL(to_char(qcgg061),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'19',(CASE INSTR(qcgg061,'.',1,1) WHEN 1 THEN '0'||qcgg061 ELSE to_char(NVL(to_char(qcgg061),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'20',(CASE INSTR(qcgg061,'.',1,1) WHEN 1 THEN '0'||qcgg061 ELSE to_char(NVL(to_char(qcgg061),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END)))
FROM qci_file,qcgg_file,tc_qcj_file",
" WHERE qcgg01 = '", g_argv3,"'",
" AND qci01 = qcgg01 AND qci00='1' ",
" AND qci02 = tc_qcj02 AND qci02=qcgg02 ",
" AND qci03 = qcgg03 AND qci03 ='",g_argv6,"'",
" AND qci041 = tc_qcj01 "
CASE
WHEN g_argv5 ='1' LET l_sql02 = l_sql02 CLIPPED," AND qcgg02 LIKE 'B%' "
WHEN g_argv5 ='2' LET l_sql02 = l_sql02 CLIPPED," AND qcgg02 LIKE 'C%' "
OTHERWISE
LET l_sql02 = l_sql02
END CASE
LET l_sql02 = l_sql02 CLIPPED," GROUP BY qcgg02,tc_qcj031,tc_qcj03,tc_qcj032,tc_qcj04,tc_qcj05,tc_qcj051,tc_qcj052 "
LET l_sql03 = " SELECT '[3]',qcgg02, tc_qcj031||tc_qcj03,tc_qcj04,tc_qcj032,TRIM(tc_qcj05) ,tc_qcj051,tc_qcj052,
WM_CONCAT(DECODE(QCGG04,'1', (CASE INSTR(qcgg062,'.',1,1) WHEN 1 THEN '0'||qcgg062 ELSE to_char(NVL(to_char(qcgg062),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'2', (CASE INSTR(qcgg062,'.',1,1) WHEN 1 THEN '0'||qcgg062 ELSE to_char(NVL(to_char(qcgg062),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'3', (CASE INSTR(qcgg062,'.',1,1) WHEN 1 THEN '0'||qcgg062 ELSE to_char(NVL(to_char(qcgg062),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'4', (CASE INSTR(qcgg062,'.',1,1) WHEN 1 THEN '0'||qcgg062 ELSE to_char(NVL(to_char(qcgg062),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'5', (CASE INSTR(qcgg062,'.',1,1) WHEN 1 THEN '0'||qcgg062 ELSE to_char(NVL(to_char(qcgg062),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'6', (CASE INSTR(qcgg062,'.',1,1) WHEN 1 THEN '0'||qcgg062 ELSE to_char(NVL(to_char(qcgg062),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'7', (CASE INSTR(qcgg062,'.',1,1) WHEN 1 THEN '0'||qcgg062 ELSE to_char(NVL(to_char(qcgg062),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'8', (CASE INSTR(qcgg062,'.',1,1) WHEN 1 THEN '0'||qcgg062 ELSE to_char(NVL(to_char(qcgg062),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'9', (CASE INSTR(qcgg062,'.',1,1) WHEN 1 THEN '0'||qcgg062 ELSE to_char(NVL(to_char(qcgg062),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'10',(CASE INSTR(qcgg062,'.',1,1) WHEN 1 THEN '0'||qcgg062 ELSE to_char(NVL(to_char(qcgg062),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'11',(CASE INSTR(qcgg062,'.',1,1) WHEN 1 THEN '0'||qcgg062 ELSE to_char(NVL(to_char(qcgg062),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'12',(CASE INSTR(qcgg062,'.',1,1) WHEN 1 THEN '0'||qcgg062 ELSE to_char(NVL(to_char(qcgg062),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'13',(CASE INSTR(qcgg062,'.',1,1) WHEN 1 THEN '0'||qcgg062 ELSE to_char(NVL(to_char(qcgg062),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'14',(CASE INSTR(qcgg062,'.',1,1) WHEN 1 THEN '0'||qcgg062 ELSE to_char(NVL(to_char(qcgg062),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'15',(CASE INSTR(qcgg062,'.',1,1) WHEN 1 THEN '0'||qcgg062 ELSE to_char(NVL(to_char(qcgg062),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'16',(CASE INSTR(qcgg062,'.',1,1) WHEN 1 THEN '0'||qcgg062 ELSE to_char(NVL(to_char(qcgg062),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'17',(CASE INSTR(qcgg062,'.',1,1) WHEN 1 THEN '0'||qcgg062 ELSE to_char(NVL(to_char(qcgg062),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'18',(CASE INSTR(qcgg062,'.',1,1) WHEN 1 THEN '0'||qcgg062 ELSE to_char(NVL(to_char(qcgg062),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'19',(CASE INSTR(qcgg062,'.',1,1) WHEN 1 THEN '0'||qcgg062 ELSE to_char(NVL(to_char(qcgg062),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END))),
WM_CONCAT(DECODE(QCGG04,'20',(CASE INSTR(qcgg062,'.',1,1) WHEN 1 THEN '0'||qcgg062 ELSE to_char(NVL(to_char(qcgg062),(case (NVL(qcgg07,' ')) when 'e0000' then 'OK' when 'E0000' then 'OK' when 'OK' then 'OK' when 'ok' then 'OK' when ' ' then ' ' else 'NG' END)) )END)))
FROM qci_file,qcgg_file,tc_qcj_file",
" WHERE qcgg01 = '", g_argv3,"'",
" AND qci01 = qcgg01 AND qci00='1' ",
" AND qci02 = tc_qcj02 AND qci02=qcgg02 ",
" AND qci03 = qcgg03 AND qci03 ='",g_argv6,"'",
" AND qci041 = tc_qcj01 "
CASE
WHEN g_argv5 ='1' LET l_sql03 = l_sql03 CLIPPED," AND qcgg02 LIKE 'B%' "
WHEN g_argv5 ='2' LET l_sql03 = l_sql03 CLIPPED," AND qcgg02 LIKE 'C%' "
OTHERWISE
LET l_sql03 = l_sql03
END CASE
LET l_sql03 = l_sql03 CLIPPED," GROUP BY qcgg02,tc_qcj031,tc_qcj03,tc_qcj032,tc_qcj04,tc_qcj05,tc_qcj051,tc_qcj052 "
###20121108 BY FMX 加入判断,不需要的不显示
IF g_argv5 ='1' THEN
SELECT NVL(SUM(qcgg06),0),NVL(SUM(qcgg061),0),NVL(SUM(qcgg062),0)
INTO l_sum01,l_sum02,l_sum03
FROM qcgg_file
WHERE qcgg01= g_argv3 AND qcgg02 LIKE 'B%' AND qcgg03 = g_argv6
GROUP BY qcgg01,qcgg03
ELSE
SELECT NVL(SUM(qcgg06),0),NVL(SUM(qcgg061),0),NVL(SUM(qcgg062),0)
INTO l_sum01,l_sum02,l_sum03
FROM qcgg_file
WHERE qcgg01= g_argv3 AND qcgg02 LIKE 'C%' AND qcgg03 = g_argv6
GROUP BY qcgg01,qcgg03
END IF
IF l_sum01 !=0 AND l_sum02 !=0 AND l_sum03 !=0 THEN
LET l_sql = l_sql01 CLIPPED," UNION ",l_sql02 CLIPPED," UNION ",l_sql03 CLIPPED
ELSE IF l_sum01 !=0 AND l_sum02 !=0 AND l_sum03 =0 THEN
LET l_sql = l_sql01 CLIPPED," UNION ",l_sql02 CLIPPED
ELSE
LET l_sql = l_sql01 CLIPPED
END IF
END IF
LET l_sql = l_sql CLIPPED," ORDER BY 2"
PREPARE r4101_pre FROM l_sql
IF SQLCA.sqlcode != 0 THEN
CALL cl_err('prepare:',SQLCA.sqlcode,1)
EXIT PROGRAM
END IF
DECLARE r4101_cur CURSOR FOR r4101_pre
FOREACH r4101_cur INTO sr.*
.
.
.
.
.
.