2014-11-03 75 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