0

更新ごとに再帰クエリを書き直すことなく、再帰クエリによって返された結果セットに対してさまざまな更新を実行したいですか?

すべての UPDATE を互いに区切る方法はありますか?

これが私のコードです:

WITH IDS (Level, $COID, $COID_REF, $CONAME) AS
  (SELECT 0, x.$COID, x.$COID_REF, x.$CONAME
    FROM MCINT.$EXT x
    WHERE $COID = X'1234567890123456'
  UNION ALL
  SELECT B.Level + 1, c.$COID, c.$COID_REF, c.$CONAME
    FROM IDS B, MCINT.$EXT C
    WHERE B.$COID_REF = C.$COID AND B.Level < 30)

-- perform first update on ther result set
SELECT COUNT(*) AS updated_rows
  FROM  FINAL TABLE
    (UPDATE MCINT.$EXT_LF 
        SET $CUR_ACC_MET_DATA = REPLACE($CUR_ACC_MET_DATA, 'p_mcint', 't_mcint')
     WHERE $COID IN (SELECT $COID_REF FROM IDS));

-- second recursive scan
WITH IDS (Level, $COID, $COID_REF, $CONAME) AS
  (SELECT 0, x.$COID, x.$COID_REF, x.$CONAME
    FROM MCINT.$EXT x
    WHERE $COID = X'1234567890123456'
  UNION ALL
  SELECT B.Level + 1, c.$COID, c.$COID_REF, c.$CONAME
    FROM IDS B, MCINT.$EXT C
    WHERE B.$COID_REF = C.$COID AND B.Level < 30)

-- perform second update on the result set
SELECT COUNT(*) AS updated_rows
  FROM  FINAL TABLE
    (UPDATE MCINT.$EXT_LF 
        SET $CUR_ACC_MET_DATA = REPLACE($CUR_ACC_MET_DATA, 'p_xcdata', 't_xcdata')
     WHERE $COID IN (SELECT $COID_REF FROM IDS));
4

1 に答える 1

0

何かを見逃していない限り、2 つのステートメントの違いは次の点だけです。

SET $CUR_ACC_MET_DATA = REPLACE($CUR_ACC_MET_DATA, 'p_mcint', 't_mcint')

対。

SET $CUR_ACC_MET_DATA = REPLACE($CUR_ACC_MET_DATA, 'p_xcdata', 't_xcdata')

その場合は、おそらく 1 回の更新で実行できます。

SET $CUR_ACC_MET_DATA = REPLACE(REPLACE($CUR_ACC_MET_DATA, 'p_mcint', 't_mcint'),
                                'p_xcdata', 't_xcdata')
于 2013-06-13T18:36:23.063 に答える