Wenn die Anzahl der Werte zu groß zu ersetzen ist, oder Sie müssen in der Lage sein, Um es einfach zu verwalten, können Sie die Zeichenfolge auch teilen, eine Dictionary-Tabelle verwenden und schließlich die Ergebnisse
aggregieren
Im Beispiel unten Ich gehe davon aus, dass die Worte in der Zeichenfolge mit blankspaces getrennt sind und die wordcount in der Zeichenfolge nicht größer sein als 100 (Pivot-Tabelle Mächtigkeit)
with Dict as
(select '{1}' String, 'myfirstval' Repl from dual
union all
select '{2}' String, 'mysecondval' Repl from dual
union all
select '{3}' String, 'mythirdval' Repl from dual
union all
select '{Nth}' String, 'myNthval' Repl from dual
)
,MyStrings as
(select 'This is the first example {1} ' Str, 1 strnum from dual
union all
select 'In the Second example all values are shown {1} {2} {3} {Nth} ', 2 from dual
union all
select '{3} Is the value for the third', 3 from dual
union all
select '{Nth} Is the value for the Nth', 4 from dual
)
,pivot as (
Select Rownum Pnum
From dual
Connect By Rownum <= 100
)
,StrtoRow as
(
SELECT rownum rn
,ms.strnum
,REGEXP_SUBSTR (Str,'[^ ]+',1,pv.pnum) TXT
FROM MyStrings ms
,pivot pv
where REGEXP_SUBSTR (Str,'[^ ]+',1,pv.pnum) is not null
)
Select Listagg(NVL(Repl,TXT),' ') within group (order by rn)
from
(
Select sr.TXT, d.Repl, sr.strnum, sr.rn
from StrtoRow sr
,dict d
where sr.TXT = d.String(+)
order by strnum, rn
) group by strnum
Mögliches Duplikat [Multiple REPLACE Funktion in Oracle] (https://stackoverflow.com/questions/2947623/multiple-replace-function-in-oracle) – Joaquinglezsantos