Aqui está um exemplo de adicionar vários sinalizadores e incrementá-los com base na instrução de caso.
WITH T3(FLAG1,FLAG2,FLAG3,tt,OTHER_DATA)
AS (
SELECT '0' FLAG1, '0' FLAG2, '0' FLAG3 , current_timestamp tt , 'dummy' OTHER_DATA
FROM dual
UNION ALL
SELECT case when cast( FLAG2 as int) > 5 then
cast ((cast(FLAG1 as int) + 1) as varchar2(30)) else FLAG1 end FLAG1,
cast((cast(FLAG2 as int) + 1) as varchar2(30)) FLAG2 ,case when (
(FLAG2 ='3') or (FLAG2 = '4')) then cast ((cast( FLAG3 as int) + 1)
as varchar2(30)) else FLAG3 end FLAG3 ,current_timestamp tt ,
'ACTUAL' OTHER_DATA FROM T3 WHERE FLAG2 < 10
)
SELECT * FROM T3
WHERE OTHER_DATA != 'dummy' ;
- O conjunto de resultados está abaixo
Flag1 Flag2 Flag3 TT OTHER_DATA
0 1 0 21-DEC-15 08.31.05.229502000 PM ASIA/CALCUTTA ACTUAL
0 2 0 21-DEC-15 08.31.05.229502000 PM ASIA/CALCUTTA ACTUAL
0 3 0 21-DEC-15 08.31.05.229502000 PM ASIA/CALCUTTA ACTUAL
0 4 1 21-DEC-15 08.31.05.229502000 PM ASIA/CALCUTTA ACTUAL
0 5 2 21-DEC-15 08.31.05.229502000 PM ASIA/CALCUTTA ACTUAL
0 6 2 21-DEC-15 08.31.05.229502000 PM ASIA/CALCUTTA ACTUAL
1 7 2 21-DEC-15 08.31.05.229502000 PM ASIA/CALCUTTA ACTUAL
2 8 2 21-DEC-15 08.31.05.229502000 PM ASIA/CALCUTTA ACTUAL
3 9 2 21-DEC-15 08.31.05.229502000 PM ASIA/CALCUTTA ACTUAL
4 10 2 21-DEC-15 08.31.05.229502000 PM ASIA/CALCUTTA ACTUAL