INSERT INTO PRM_REKENING (NOMOR_REKENING, KD_DEBITUR, KD_CABANG, KD_PRODUK, KET_PRODUK, KD_MATA_UANG, TGL_BUKA,
                          LIMIT_REF, STATUS_REKENING, STATUS_DATA, FLAG_OTO, TGL_UPDATE)
SELECT ACCOUNT_NUMBER,
       CASE
           WHEN CUSTOMER_CODE IS NULL THEN
               0
           ELSE CUSTOMER_CODE
           END      AS KD_DEBITUR,
       BRANCH_CODE,
       a.PRODUCT_CODE,
       PRODUCT_DESCRIPTION,
       CURRENCY_CODE,
       OPENING_DATE,
       CASE
           WHEN MINIMUM_BALANCE IS NULL THEN
               0
           ELSE minimum_balance
           END      AS LIMIT_REF,
       CASE

           WHEN INACTIVE_FLAG IS NULL THEN
               'N'
           ELSE 'Y'
           END      AS STATUS_REKENING,
       CASE
           WHEN INACTIVE_FLAG IS NULL THEN
               'N'
           ELSE 'Y'
           END      AS STATUS_DATA,
       '1'          AS FLAG_OTO,
       CURRENT_dATE AS TGL_UPDATE
FROM T_aCCOUNT @t24dwh_96 a
	INNER JOIN T_PRODUCT @T24DWH_96 b
ON a.product_code = b.product_code;
