Let us say I have a string of 16k characters which may contain a comma(,) at many positions but I want to replace the commas(,) at the position 4001,8001,12001 only with null
There may be commas(,) at other positions for example 4002 which shouldn't be replaced.
Sample data below
WITH data
AS (SELECT To_clob(Lpad('A', 4000, '0'))
||To_clob(Lpad('A', 4000, '0'))
||To_clob(Lpad('A', 4000, '0'))
||To_clob(Lpad('A', 4000, '0'))
||To_clob(Lpad('A', 4000, '0')) AS file_data
FROM dual),
data1
AS (SELECT LEVEL
lvl
,
Substr(file_data, Decode(LEVEL, 1, LEVEL,
( ( LEVEL - 1 ) * 4000 ) + 1),
4000)
file_data,
1
order1
FROM data
CONNECT BY ( ( LEVEL - 1 ) * 4000 ) + 4000 <= Length(file_data))
SELECT Wm_concat(To_clob(file_data)) file_data
FROM data1;
wm_concatwas never documented (and therefore supported), and on my version, 12.2, it is not recognized. However, if it does work for you, here is a possible approach: chunk the input into 4000 character pieces; then, for each piece, computenullif(substr(piece, 1, 1), ',') || substr(piece, 2); and then callwm_concaton these results.