Oracle SQL:从CLOB字段中选择特定字符串
我有一个表,其中一个字段是CLOB,它存储错误消息信息 字段CLOB包含以下内容:Oracle SQL:从CLOB字段中选择特定字符串,sql,oracle,Sql,Oracle,我有一个表,其中一个字段是CLOB,它存储错误消息信息 字段CLOB包含以下内容: oracle.retail.sim.common.core.SimServerException: Error processing message! [Inbound: true, MessageType: ItemLocCre, BusinessId: 1101505002] at oracle.retail.sim.service.mps.SimMessageCommand.buildExcepti
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;
我假装只选择包含“由..引起”字符串的行。我只需要提取以下错误消息:
Item not found for Id: 1101505002
是否可以仅使用select语句执行此操作
提前感谢,,
非常感谢,下面的查询(替换实际的表名和列名)将从由引起的单词提取一行文本,直到该行的末尾。文本行是否以由
引起的开头并不重要-您将只获得从这些单词到行尾的所有内容
如果需要一个较短的子字符串,则需要更详细地解释如何“识别”——如何决定哪些内容可以省略,哪些内容必须返回。这是如何界定的
select regexp_substr(message, 'Caused by:.*) as caused_line
from test_data;
(请注意,默认情况下,通配符
与Oracle正则表达式中的行尾不匹配。)向我们展示您的存储过程Hello不是过程,只是一个用于报告建议的简单查询。“PL/SQL输出”在哪里如果您没有存储过程,那么它是从哪里来的?您好,在plsql developer中执行select语句时它会直接出现。我需要的是一个函数,该函数只检索包含字符串原因的句子。Mathguy的回答与预期一样有效。ThanksHello,这确实起到了作用。为了使clob在输出中直接可见,而无需打开所有clob文件:dbms\u lob.substr(regexp\u substr(message\u error,'Caused by:.*'),4000,1)作为错误消息
谢谢,我不会试图从输出中删除Caused by:。