안녕하세요.
제가 오라클쿼리를 mysql로 바꾸려고 하는데 자꾸 에러가 납니다.
하나 고치면 다른 하나가 나고 그러다가 해당 에러내용에서 막혔습니다.
서포트좀 부탁드립니다.
에러내용----------------------------------------------------------------------
SQL Error [1064] [42000]: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '),
RISK_JOB AS
(
SELECT
' at line 1
--------------------------------------------------------------------------------------
sql문----------------------------------------------------------------------
MERGE INTO AML_CUSTOMER_INDV X
USING (
WITH
CUST AS
(
SELECT
A.SYSTEM_DIV
, A.CUSTOMER_NO
, B.BUSINESS_DTL_CD -- 직업코드
FROM AML_CUSTOMER_BASE A
, AML_CUSTOMER_INDV B
WHERE A.SYSTEM_DIV = B.SYSTEM_DIV
AND A.CUSTOMER_NO = B.CUSTOMER_NO
AND A.SYSTEM_DIV = 'WMPPG'
AND A.CUSTOMER_NO IN
(
SELECT
X.CUSTOMER_NO
FROM
(
SELECT
SYSTEM_DIV AS SYSTEM_DIV
, DEST_ID AS CUSTOMER_NO
, MAX(LAST_CHANGE_DT) AS LAST_CHANGE_DT
FROM WL_SEARCH_RST
WHERE SYSTEM_DIV = 'WMPPG'
AND DEST_DIV = '1'
AND LAST_CHANGE_DT BETWEEN CONCAT( '20200524', '000000000' ) AND CONCAT( '20200524', '999999999' )
GROUP BY
SYSTEM_DIV
, DEST_ID
) X
, AML_CUSTOMER_INFO Y
WHERE X.SYSTEM_DIV = Y.SYSTEM_DIV
AND X.CUSTOMER_NO = Y.CUSTOMER_NO
AND X.LAST_CHANGE_DT > Y.LAST_CHANGE_DT
)
),
RISK_JOB AS
(
SELECT
RISK_FACTOR_CD AS RISK_FACTOR_CD
, SECTION_CD1 AS SECTION_CD1
, SECTION_CD2 AS MIN_SCORE
, SECTION_CD3 AS MAX_SCORE
FROM
(
SELECT
RISK_FACTOR_CD AS RISK_FACTOR_CD
, SECTION_CD1 AS SECTION_CD1
, SECTION_CD2 AS SECTION_CD2
, SECTION_CD3 AS SECTION_CD3
, RATING_SCORE AS RATING_SCORE
, ROW_NUMBER() OVER(PARTITION BY RISK_FACTOR_CD, SECTION_CD1 ORDER BY VALID_START_DD DESC, SEQ_NO DESC) AS SEQ
FROM AML_RISKFACTOR_DTL
WHERE SYSTEM_DIV = 'WMPPG'
AND KYC_TMS_DIV = '01' -- 01:KYC
AND CUSTOMER_DIV = '01' -- 01:개인
AND RISK_FACTOR_CD = '02' -- 02:직업
AND APPR_STS_CD = '04' -- 결재승인
AND RISK_CLASS_CD = 'H'
AND VALID_START_DD <= TO_CHAR(now(3), 'YYYYMMDD') -- 적용시작일자
AND VALID_CLOSE_DD >= TO_CHAR(now(3), 'YYYYMMDD') -- 적용종료일자
) A
WHERE SEQ = 1
)
SELECT
A.SYSTEM_DIV
, A.CUSTOMER_NO
, CASE WHEN C.RISK_FACTOR_CD IS NOT NULL THEN 'Y' ELSE 'N' END AS HI_DANGER_JOB_YN -- 고위험 직업군 여부
FROM CUST A
RIGHT JOIN RISK_JOB C
ON A.BUSINESS_DTL_CD = C.SECTION_CD1
) Y
ON (
X.SYSTEM_DIV = Y.SYSTEM_DIV
AND X.CUSTOMER_NO = Y.CUSTOMER_NO
)
WHEN MATCHED THEN
UPDATE SET
HI_DANGER_JOB_YN = Y.HI_DANGER_JOB_YN -- 1 고위험 직업군 여부
WHEN NOT MATCHED THEN
INSERT
(
SYSTEM_DIV -- 1 시스템_구분
, CUSTOMER_NO -- 2 고객_번호
, HI_DANGER_JOB_YN -- 3 고위험 직업군 여부
, REG_USER_ID -- 4 등록_직원_ID
, REG_DT -- 5 등록_일시
, LAST_CHANGE_USER_ID -- 6 최종_변경_직원_ID
, LAST_CHANGE_DT -- 7 최종_변경_일시
, CREATE_DT -- 8 생성_일시
)
VALUES
(
Y.SYSTEM_DIV -- 1 시스템_구분
, Y.CUSTOMER_NO -- 2 고객_번호
, Y.HI_DANGER_JOB_YN -- 3 고위험 직업군 여부
, 'SYSTEM' -- 4 REG_USER_ID
, TO_CHAR(CURRENT_TIMESTAMP, 'YYYYMMDDHH24MISSFF3') -- 5 REG_DT
, 'SYSTEM' -- 6 LAST_CHANGE_USER_ID
, TO_CHAR(CURRENT_TIMESTAMP, 'YYYYMMDDHH24MISSFF3') -- 7 LAST_CHANGE_DT
, TO_CHAR(CURRENT_TIMESTAMP, 'YYYYMMDDHH24MISSFF3') -- 8 CREATE_DT
)
-----------------------------------------------------------------------------------