更新ごとに再帰クエリを書き直すことなく、再帰クエリによって返された結果セットに対してさまざまな更新を実行したいですか?
すべての 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));