Advertisement
Wiy

Скрипт миграции

Wiy
Dec 2nd, 2020 (edited)
248
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     INSERT INTO CONSENT_OPERATION (ID, CONSENT_ID, ACTION_TYPE, STATUS, PACK_NUMBER, UPDATE_TIME, TB_CODE)
  2.     SELECT CONSENT_OPERATION_SEQ.NEXTVAL AS ID, C.ID AS CONSENT_ID,
  3.            (CASE
  4.                WHEN C.STATUS = 1 OR (C.STATUS = 0 AND ACTION_TYPE = 'REVOKE')
  5.                THEN 'CONSENT'
  6.                ELSE 'REVOKE'
  7.            END) AS ACTION_TYPE,
  8.            'Wait' AS STATUS,
  9.            CONSENT_OPERATION_SEQ.NEXTVAL AS PACK_NUMBER,
  10.            SYSDATE AS UPDATE_TIME,
  11.            TBIDENTCODE AS TB_CODE
  12.     FROM CONSENT C
  13.              join CONSENT_OPERATION cp ON C.ID = cp.CONSENT_ID
  14.              join USERINFO UI ON C.USERINFO_ID = UI.USERINFOID
  15.              join OFFICE OFF ON UI.OFFICEID = OFF.ID
  16.              join BRANCH B ON OFF.OWNEROFFICEID = B.ID
  17.     WHERE C.ID NOT IN (SELECT c.ID FROM CONSENT c
  18.     join CONSENT_OPERATION co ON c.ID = CO.CONSENT_ID)
  19.     AND C.PPRB_USK_ID IS NULL;
Advertisement
RAW Paste Data Copied
Advertisement