There is a string:
{([ab1]+[ab2])*([bc1]+[bc2])*([cd2]+[cd3])}
And a collection (table of pls_integer index by varchar2(3)):
[ab1] := 1000
[cd3] := 1000
[bc1] := 10000
[cd2] := 10000
[bc2] := 20000
[ab2] := 20000
FYI: This collection is filled via SELECT, so could be used in problem which is described lower:
My goal is to replace symbols in string with an amount from this collection, and get:
'(1000+20000)*(10000+20000)*(10000+1000)'
I have already done this in PL/SQL using loop, then via regexp find first occurence of 3-char symbol, replacing etc. etc.
MY question: is it possible to do it in one query?
Sample select:
SELECT '[ab1]' AS symbol, 1000 AS amt from dual union all
SELECT '[cd3]',1000 from dual union all
SELECT '[bc1]',10000 from dual union all
SELECT '[cd2]',10000 from dual union all
SELECT '[bc2]',20000 from dual union all
SELECT '[ab2]',20000 from dual;
(1000+20000)*(10000+20000)*(10000+1000)? - Joachim Isaksson