2017-02-02 14 views
0

フィールドの1つがCLOBのテーブルがあり、エラーメッセージ情報が格納されています。Oracle SQL:CLOBフィールドから特定の文字列を選択

次コンテンツとしてのフィールドCLOB:

oracle.retail.sim.common.core.SimServerException: Error processing message! [Inbound: true, MessageType: ItemLocCre, BusinessId: 1101505002] 
    at oracle.retail.sim.service.mps.SimMessageCommand.buildException(Unknown Source) 
    at oracle.retail.sim.service.mps.SimMessageProcessCommand.doExecute(Unknown Source) 
    at oracle.retail.sim.common.core.Command.execute(Unknown Source) 
    at sun.reflect.GeneratedMethodAccessor273.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:606) 
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:221) 
Caused by: oracle.retail.sim.common.core.SimServerException: Item not found for Id: 1101505002 
    at oracle.retail.sim.server.integration.consumer.itemloc.ItemLocConsumer.buildItemNotFoundException(Unknown Source) 
    at oracle.retail.sim.server.integration.consumer.itemloc.ItemLocCreateConsumer.handleMessage(Unknown Source) 
    at oracle.retail.sim.server.integration.consumer.itemloc.ItemLocCreateConsumer.handleMessage(Unknown Source) 
    at oracle.retail.sim.server.integration.consumer.SimMessageConsumerFactory.consume(Unknown Source) 
    ... 56 more 

イム、直接PL/SQL出力の​​CLOBの結果を表示しようとすると、次のクエリを使用してイムので:

select id, dbms_lob.substr(message_error, 4000, 1) AS ERROR_MESSAGE 
    from THE_TABLE; 

私がふりをしているのは、 'Caused by ..'という文字列を含む行だけを選ぶことです。私が必要とするのは、次のエラーメッセージだけを抽出することです:

Item not found for Id: 1101505002 

select文だけでも可能ですか?事前に

おかげで、 敬具、

+0

は –

+0

こんにちは、手順はありませんが、私達にあなたのストアドプロシージャを表示します提案を報告するために使用される単純なクエリです。 –

+0

ストアドプロシージャがない場合、 "PL/SQL出力"はどこから来ますか? –

答えて

0

は、次のクエリは、(あなたの実際のテーブル名とカラム名に置き換えてください)の言葉Caused byからその行の最後に、テキストの1行を抽出します。テキストの行がCaused byで始まるかどうかは関係ありません。あなたはそれらの単語から行末までのすべてを取得します。

より短いサブストリングが必要な場合は、どのように「認識」できるかを詳しく説明する必要があります。それはどのように区切られていますか?

select regexp_substr(message, 'Caused by:.*) as caused_line 
from test_data; 

(デフォルトではワイルドカード文字.は、Oracleの正規表現では行末に一致しないこと。注意してください)

+0

こんにちは これは、すべてのclobファイルを開く必要なしに直接出力で見えるようにするために以下を使用しました: 'dbms_lob.substr(regexp_substr(message_error、 '原因:*。 ')、4000、1)AS error_message' ありがとうございます。ありがとうございます、私は**原因を削除する方法を見つけようとしません:**出力から。 –

関連する問題