programing

이 Oracle 쿼리를 MariaDB로 올바르게 변환하는 방법은 무엇입니까?

powerit 2023. 9. 10. 13:11
반응형

이 Oracle 쿼리를 MariaDB로 올바르게 변환하는 방법은 무엇입니까?

다음 Oracle 쿼리를 변환하려고 합니다.

SELECT a.agt_code                         Agent_Id
     , a.trx_dt                           Request_Date
     , a.f004                             P2P_Ref_No
     , a.f005                             P2P_Cif_No
     , b.ref_no                           Loan_Ref_No
     , b.cix_no                           Cif_No
     , b.com_id                           Product_Id
     , TO_CHAR(b.open_il, 'YYYYMMDD')     Fisburse_Date
     , TO_CHAR(b.tot_exp_il, 'YYYYMMDD')  Expiry_Date
     , b.fst_lon_amt                      Disburse_Amount
     , TO_CHAR(b.nx_repay_il, 'YYYYMMDD') Next_Principal_Date
     , c.plan_amt                         Next_Repay_Principal
     , TO_CHAR(b.nx_isu_il, 'YYYYMMDD')   Next_Interest_Date
     , d.plan_amt                         Next_Repay_Interest
     , c.plan_amt + d.plan_amt            Next_Repay_Total
  FROM adst_lnb_acl_dl a
     , adst_lnb_base b
     , ( SELECT a.*
           FROM adst_lnb_sch  a
              , adst_lnb_base b
          WHERE a.ref_no  = b.ref_no
            AND a.sts     = '0'
            AND a.adj_seq = 0
            AND a.sch_seq = b.repay_nx_seq
            AND a.sch_gb  = '001' ) c
     , ( SELECT a.*
           FROM adst_lnb_sch  a
              , adst_lnb_base b
          WHERE a.ref_no  = b.ref_no
            AND a.sts     = '0'
            AND a.adj_seq = 0
            AND a.sch_seq = b.int_nx_seq
            AND a.sch_gb  = '002' ) d
     , acom_cont_base e
WHERE a.lnb_ref_no = b.ref_no
   AND b.ref_no     = c.ref_no
   AND b.ref_no     = d.ref_no
   AND b.ref_no     = e.ref_no
   AND a.trx_dt     = '2020/12/21'
   AND a.agt_code   = 'CLP003'
   AND e.sts        = '0'
ORDER BY a.trx_dt, a.agt_code, a.facility_seq, a.no_batch, a.seq_no

오라클은 내 취향이 아닙니다.제가 MySQL에 더 익숙합니다.제 번역은 이렇습니다.

SELECT a.AGT_CODE              as            "Agent_Id"
     , a.trx_dt                as           "Request_Date"
     , a.f004                  as          "P2P_Ref_No"
     , a.f005                  as "P2P_Cif_No"
     , b.ref_no                as "Loan_Ref_No"
     , b.cix_no                as           "Cif_No"
     , b.com_id                as "Product_Id"
     , DATE_FORMAT(b.open_il, '%Y%M%d') as    "Disburse_Date"
     , date_format(b.tot_exp_il, '%Y%M%d')  as "Expiry_Date"
     , b.fst_lon_amt            as "Disburse_Amount"
     , date_format(b.nx_repay_il, '%Y%M%d') as "Next_Principal_Date"
     , c.plan_amt                         as "Next_Repay_Principal"
     , date_format(b.nx_isu_il, '%Y%M%d')   as "Next_Interest_Date"
     , d.plan_amt                         as "Next_Repay_Interest"
     , c.plan_amt + d.plan_amt            as "Next_Repay_Total"
  FROM inoan_adst_lnb_acl_dl a
     , inoan_adst_lnb_base b
     , ( SELECT a.*
           FROM inoan_adst_lnb_sch  a
              , inoan_adst_lnb_base b
          WHERE a.ref_no  = b.ref_no
            AND a.sts     = '0'
            AND a.adj_seq = 0
            AND a.sch_seq = b.repay_nx_seq
            AND a.sch_gb  = '001' ) c
     , ( SELECT a.*
           FROM inoan_adst_lnb_sch  a
              , inoan_adst_lnb_base b
          WHERE a.ref_no  = b.ref_no
            AND a.sts     = '0'
            AND a.adj_seq = 0
            AND a.sch_seq = b.int_nx_seq
            AND a.sch_gb  = '002' ) d
     , inon_acom_cont_base e
WHERE a.lnb_ref_no = b.ref_no
   AND b.ref_no     = c.ref_no
   AND b.ref_no     = d.ref_no
   AND b.ref_no     = e.ref_no
   AND a.trx_dt     = '2020/12/21'
   AND a.agt_code   = 'CLP003'
   AND e.sts        = '0'
ORDER BY a.trx_dt, a.agt_code, a.facility_seq, a.no_batch, a.seq_no

다음 오류 메시지가 표시됨:

SQL 오류 [1064] [42000]:SQL 구문에 오류가 있습니다. MariaDB 서버 버전에 해당하는 설명서에서 행 1에서 'Agent_Id', a.trx_dtas...' 근처에서 사용할 올바른 구문을 확인하십시오.

여기 왜 이래요?

MariaDB join과 Oracle join 구문이 상당히 비슷합니다.

마리아DB 오라클

언급URL : https://stackoverflow.com/questions/65559130/how-to-properly-translate-this-oracle-query-to-mariadb

반응형