Where The Streets Have No Name

선택적 복제 본문

Developement/DataBase

선택적 복제

highheat 2008. 2. 7. 00:52

jikgub_cd를 3으로 나누어서 나머지에 따라서 복제가 일어나게끔...

1 => 1개복제
2 => 2개복제
0 => 3개복제

SELECT MOD (TO_NUMBER (A.JIKGUB_CD), 3) AS COPY_CNT, B.RN,
       A.*
  FROM ORG201 A,
       (SELECT     ROWNUM AS RN
              FROM DUAL
        CONNECT BY LEVEL <= 3) B
WHERE '20080205' BETWEEN SDATE AND EDATE
   AND B.RN BETWEEN 1
                AND DECODE (MOD (TO_NUMBER (A.JIKGUB_CD), 3),
                            0, 3,
                            MOD (TO_NUMBER (A.JIKGUB_CD), 3)
;