2014-11-03 79 views
0

我有数据,如低于一次(有5条记录)需要帮助REGEXP_SUBSTR和REGEXP_LIKE

Failed to process Batch task. An exception occured while building Bond(00010068, BOND, CLOSE, ICT, TOK, EOD, Bond_EOD): You are trying to get DBond that doesn't exist. (DeliveryCount=2) 
Failed to process Batch task. An exception occured while building Bond(00010068, BOND, CLOSE, ICT, TOK, EOD, Bond_EOD): You are trying to get DBond that doesn't exist. (DeliveryCount=0) 
Failed to process Batch task. There was an error generating the XML document. (DeliveryCount=0) 
Failed to process Batch task. There was an error generating the XML document. (DeliveryCount=0) 
Failed to process Batch task. There was an error generating the XML document. (DeliveryCount=0) 

在这里,我需要得到像(需要根据()eclosed数据)

数据列
00010068, BOND, CLOSE, ICT, TOK, EOD, Bond_EOD 
00010068, BOND, CLOSE, ICT, TOK, EOD, Bond_EOD 

我不想去上面提到的其他数据。

除了有

col1  col2 col3  col4 col5  col6 col7 
------------------------------------------------------------------------- 
00010068 BOND CLOSE  ICT  TOK  EOD  Bond_EOD 

能否请您一定的帮助我在这

回答

0
with tab as 
(select 'Failed to process Batch task. An exception occured while building Bond(00010068, BOND, CLOSE, ICT, TOK, EOD, Bond_EOD): You are trying to get DBond that doesn''t exist. (DeliveryCount=2)' s from dual 
union all select 'Failed to process Batch task. An exception occured while building Bond(00010068, BOND, CLOSE, ICT, TOK, EOD, Bond_EOD): You are trying to get DBond that doesn''t exist. (DeliveryCount=0)' from dual 
union all select 'Failed to process Batch task. There was an error generating the XML document. (DeliveryCount=0)' from dual 
union all select 'Failed to process Batch task. There was an error generating the XML document. (DeliveryCount=0)' from dual 
union all select 'Failed to process Batch task. There was an error generating the XML document. (DeliveryCount=0)' from dual 
) 
select trim(regexp_substr(parsed, '[^,]+', 1, 1)) col1 
     , trim(regexp_substr(parsed, '[^,]+', 1, 2)) col2 
     , trim(regexp_substr(parsed, '[^,]+', 1, 3)) col3 
     , trim(regexp_substr(parsed, '[^,]+', 1, 4)) col4 
     , trim(regexp_substr(parsed, '[^,]+', 1, 5)) col5 
     , trim(regexp_substr(parsed, '[^,]+', 1, 6)) col6 
     , trim(regexp_substr(parsed, '[^,]+', 1, 7)) col7 
from 
(
    select substr(regexp_substr(s, 'bond\([^)]+', 1, 1, 'i'), 6) parsed 
    from tab where regexp_like(s, 'bond\(.+?\)', 'i') 
); 

regexp_like(s, 'bond\(.+?\)', 'i')返回true行数据拆分成多列一样,如果一个字符串小号包含“债券(...)“,不区分大小写(”我“); .+?是至少一个符号 - 任何东西,直到第一个“)”

substr(regexp_substr(s, 'bond\([^)]+', 1, 1, 'i'), 6) - 只获得所需的子串(...从“债券(...)”)。 Oracle10g中不支持子表达式,所以我们必须做出共同SUBSTR做切“键(”

最后,从分析的字符串获得第N个“无逗号”序列

+0

Thanq将检查该 – 2014-11-03 17:13:24