【发布时间】:2020-01-20 20:22:01
【问题描述】:
有一个字符串:
{([ab1]+[ab2])*([bc1]+[bc2])*([cd2]+[cd3])}
还有一个集合(pls_integer index by varchar2(3)):
[ab1] := 1000
[cd3] := 1000
[bc1] := 10000
[cd2] := 10000
[bc2] := 20000
[ab2] := 20000
仅供参考:这个集合是通过SELECT 填充的,所以可以用于下面描述的问题:
我的目标是用这个集合中的数量替换字符串中的符号,并得到:
'(1000+20000)*(10000+20000)*(10000+1000)'
我已经在 PL/SQL 中使用循环完成了这项工作,然后通过正则表达式找到第一次出现的 3 字符符号,替换等。
我的问题:是否可以在一个查询中完成?
样本选择:
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)的字符串? -
是的,对不起,我忘了提,更新问题