Hello,
how can one achieve this:
SELECT
regexp_replace(
replace
(replace
(replace
(replace
(replace
(replace
(replace
(replace
(replace
(replace
(replace
(replace
(
replace ( replace ( REPLACE ( REPLACE ( REPLACE ( query, '`', '''' ), '$*tab', 'H' || UPPER ( 'USTVA' ) ),'$*tab', 'HTAB' ), chr (13), ''), chr (10), '') --v_stmt
, 'select', chr(10) || 'select ') --replace select with new line + select
, 'from ', chr(10) || 'from ') --replace from with new line + from
, 'where ', chr(10) || 'where ') --replace where with new line + where
, 'and ' , chr(10) || 'and ') --replace and with new line + and
, 'group by ', chr(10) || 'group by ') --replace group by with new line + group by
, 'set ' , chr(10) || 'set ') --replace set with new line + set
, 'case ', chr(10) || chr(9) || 'case ') --replace case with new line + tab + case
,'when ', chr(10) || chr(9) || chr(9) || 'when ') --replace when with new line + tab + tab + when
,'then ', chr(10) || chr(9) || chr(9) || chr(9) || 'then ') --replace then with new line + tab + tab + tab + then
,'else ', chr(10) || chr(9) || chr(9) || 'else ') --replace else with new line + tab + tab + else
, 'end ', chr(10) || chr(9) || 'end ') --replace end with new line + tab + end
, ',', ',' || chr(10)) --replace ',' with new line + ','
,'(','(' || chr(10),1,1) --replace first ( with ( + new line