最適化する必要がある SQL クエリがあり、7 月 1 日から 8 月 20 日までcp_ex_dtフィールドをループします。現在、日付ごとに個別に実行し、出力をcsvファイルに保存する必要があります。誰かがこれを実行するための最良の方法を提案できますか? ラピッド SQL で使用できるものはありますか? 私の会社ではJavaの実行が許可されていないことに注意してください。
ご検討いただきありがとうございます。
SELECT A.S_A
,C.I_N
,C.P_A_I
,C.P_A_I_TYPE
,C.C_C
,'Tel'
,A.T_T AS T_T_Tel
,A.D_A AS D_A_Tel
,A.C_E_D AS E_D_Tel
,A.C_P_D AS P_D_Tel
,'BBG'
,D.T_T AS T_T_BB
,D.D_A AS D_A_BB
,D.C_E_D AS E_D_BB
,D.C_P_D AS P_D_BB
,'Ext'
,E.T_T AS T_T_Ext
,E.D_A AS D_A_Ext
,E.C_E_D AS E_D_Ext
,E.C_P_D AS P_D_Ext
FROM TO.CP_A_HIS A
,PA_MA.IN B
,SE.SE_MA C
,TO.CP_A_HIS D
,TO.CP_A_HIS E
WHERE A.T_T = 'CASHDIV'
AND A.C_S = 'PD'
AND A.S_A = C.S_A
AND A.S_I_INST = B.INST
AND A.CP_EX_DT = '1-Jul-2014'
AND A.S_I_INST = 46
AND A.S_A = D.S_A(+)
AND A.T_T = D.T_T(+)
AND A.CP_EX_DT = D.CP_EX_DT(+)
AND D.C_S(+) = 'PD'
AND D.S_I_INST(+) = 45
AND (A.CP_REA = 'REG'
AND D.CP_REA(+) IN ('final','REG','REG cash','partnership dst'))
AND D.UPDATE_DATE(+) > '16-Apr-2014'
AND A.S_A = E.S_A(+)
AND A.T_T = E.T_T(+)
AND A.CP_EX_DT = E.CP_EX_DT(+)
AND E.C_S(+) = 'PD'
AND E.S_I_INST(+) = 51
AND A.CP_REA = E.CP_REA(+)
UNION
SELECT A.S_A
,C.I_N
,C.P_A_I
,C.P_A_I_TYPE
,C.C_C
,'Tel'
,A.T_T AS T_T_Tel
,A.D_A AS D_A_Tel
,A.C_E_D AS E_D_Tel
,A.C_P_D AS P_D_Tel
,'BBG'
,D.T_T AS T_T_BB
,D.D_A AS D_A_BB
,D.C_E_D AS E_D_BB
,D.C_P_D AS P_D_BB
,'Ext'
,E.T_T AS T_T_Ext
,E.D_A AS D_A_Ext
,E.C_E_D AS E_D_Ext
,E.C_P_D AS P_D_Ext
FROM TO.CP_A_HIS A
,PA_MA.IN B
,SE.SE_MA C
,TO.CP_A_HIS D
,TO.CP_A_HIS E
WHERE A.T_T = 'CASHDIV'
AND A.C_S = 'PD'
AND A.S_A = C.S_A
AND A.S_I_INST = B.INST
AND A.CP_EX_DT = '1-Jul-2014'
AND A.S_I_INST = 46
AND A.S_A = D.S_A(+)
AND A.T_T = D.T_T(+)
AND A.CP_EX_DT = D.CP_EX_DT(+)
AND D.C_S(+) = 'PD'
AND D.S_I_INST(+) = 45
AND (A.CP_REA = 'SPECIAL'
AND D.CP_REA(+) IN ('special cash','SPECIAL'))
AND D.UPDATE_DATE(+) > '16-Apr-2014'
AND A.S_A = E.S_A(+)
AND A.T_T = E.T_T(+)
AND A.CP_EX_DT = E.CP_EX_DT(+)
AND E.C_S(+) = 'PD'
AND E.S_I_INST(+) = 51
AND A.CP_REA = E.CP_REA(+)
UNION
SELECT D.S_A
,C.I_N
,C.P_A_I
,C.P_A_I_TYPE
,C.C_C
,'Tel'
,A.T_T AS T_T_Tel
,A.D_A AS D_A_Tel
,A.C_E_D AS E_D_Tel
,A.C_P_D AS P_D_Tel
,'BBG'
,D.T_T AS T_T_BB
,D.D_A AS D_A_BB
,D.C_E_D AS E_D_BB
,D.C_P_D AS P_D_BB
,'Ext'
,E.T_T AS T_T_Ext
,E.D_A AS D_A_Ext
,E.C_E_D AS E_D_Ext
,E.C_P_D AS P_D_Ext
FROM TO.CP_A_HIS A
,PA_MA.IN B
,SE.SE_MA C
,TO.CP_A_HIS D
,TO.CP_A_HIS E
WHERE D.T_T = 'CASHDIV'
AND D.C_S = 'PD'
AND D.S_A = C.S_A
AND D.S_I_INST = B.INST
AND D.CP_EX_DT = '1-Jul-2014'
AND D.S_I_INST = 45
AND A.S_A(+) = D.S_A
AND A.T_T(+) = D.T_T
AND A.CP_EX_DT(+) = D.CP_EX_DT
AND A.C_S(+) = 'PD'
AND A.S_I_INST(+) = 46
AND (A.CP_REA(+) = 'SPECIAL'
AND D.CP_REA IN ('special cash','SPECIAL'))
AND D.UPDATE_DATE > '16-Apr-2014'
AND A.INST IS NULL
AND D.S_A = E.S_A(+)
AND D.T_T = E.T_T(+)
AND D.CP_EX_DT = E.CP_EX_DT(+)
AND E.C_S(+) = 'PD'
AND E.S_I_INST(+) = 51
AND (E.CP_REA(+) = 'SPECIAL'
AND D.CP_REA IN ('special cash','SPECIAL'))
UNION
SELECT D.S_A
,C.I_N
,C.P_A_I
,C.P_A_I_TYPE
,C.C_C
,'Tel'
,A.T_T AS T_T_Tel
,A.D_A AS D_A_Tel
,A.C_E_D AS E_D_Tel
,A.C_P_D AS P_D_Tel
,'BBG'
,D.T_T AS T_T_BB
,D.D_A AS D_A_BB
,D.C_E_D AS E_D_BB
,D.C_P_D AS P_D_BB
,'Ext'
,E.T_T AS T_T_Ext
,E.D_A AS D_A_Ext
,E.C_E_D AS E_D_Ext
,E.C_P_D AS P_D_Ext
FROM TO.CP_A_HIS A
,PA_MA.IN B
,SE.SE_MA C
,TO.CP_A_HIS D
,TO.CP_A_HIS E
WHERE D.T_T = 'CASHDIV'
AND D.C_S = 'PD'
AND D.S_A = C.S_A
AND D.S_I_INST = B.INST
AND D.CP_EX_DT = '1-Jul-2014'
AND D.S_I_INST = 45
AND A.S_A(+) = D.S_A
AND A.T_T(+) = D.T_T
AND A.CP_EX_DT(+) = D.CP_EX_DT
AND A.C_S(+) = 'PD'
AND A.S_I_INST(+) = 46
AND (A.CP_REA(+) = 'REG'
AND D.CP_REA IN ('final','REG','REG cash','partnership dst'))
AND D.UPDATE_DATE > '16-Apr-2014'
AND A.INST IS NULL
AND D.S_A = E.S_A(+)
AND D.T_T = E.T_T(+)
AND D.CP_EX_DT = E.CP_EX_DT(+)
AND E.C_S(+) = 'PD'
AND E.S_I_INST(+) = 51
AND (E.CP_REA(+) = 'REG'
AND D.CP_REA IN ('final','REG','REG cash','partnership dst'))