<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Rex in Case command? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Rex-in-Case-command/m-p/27832#M5451</link>
    <description>&lt;P&gt;You can't put just any command into an eval statement - you can only use the &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions"&gt;eval functions&lt;/A&gt;. &lt;/P&gt;

&lt;P&gt;Also, you seem to be trying to do this in an "if then else" in a procedural kind of way. You need to rethink that with Splunk.&lt;/P&gt;

&lt;P&gt;Try this instead&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=_raw "customers:\s+(?&amp;lt;product_code&amp;gt;.*?)\("
| rex field=_raw "pro_codes were not mapped:\s+(?&amp;lt;product_code&amp;gt;.*?)\;"
| rex field=_raw "pro_codes\s+= \s+(?&amp;lt;product_code&amp;gt;.*?)\)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Splunk will only create the &lt;CODE&gt;product_code&lt;/CODE&gt; field when the event matches the regular expression; each event will (hopefully) only match one of them.&lt;/P&gt;</description>
    <pubDate>Thu, 09 May 2013 01:11:51 GMT</pubDate>
    <dc:creator>lguinn2</dc:creator>
    <dc:date>2013-05-09T01:11:51Z</dc:date>
    <item>
      <title>Rex in Case command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-in-Case-command/m-p/27831#M5450</link>
      <description>&lt;P&gt;Hi All&lt;/P&gt;

&lt;P&gt;In the logs there are multiple Oracle codes with different reasons e.g.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Product Mapping Error ORA-20030: PKG_PRODUCTMAPPING.Usp_Getsyscodesforprocodes failed while checking if list of inputted pro_codes have all successfully been mapped. For network the following pro_codes were not mapped: A100036;

Product Mapping Error ORA-20029: PKG_PRODUCTMAPPING.Setdownstreammapping failed while checking for more than one possible sys_code mapping for a given pro_code (see sys_product_mapping for pro_code = D102124).

Product Mapping Error ORA-20027: PKG_PRODUCTMAPPING.Setdownstreammapping failed while checking list of PRO_CODE(s) for effective_date of 21-Apr-2013 00:00. List of products that don't have a status of Live for NEW customers: D102683(Withdrawn);
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there a way to extract the code (A100036, D102124, D102683) depending on the Oracle error code?&lt;/P&gt;

&lt;P&gt;I've been trying the following but getting an error saying "Error in 'eval' command: The expression is malformed. Expected )".&lt;/P&gt;

&lt;P&gt;eval product_code=case( oracle_error_code=="ORA-20027", rex field=_raw "customers: (?&amp;lt;"product_code1.*&amp;gt;)(Withdrawn);" )&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2013 16:10:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-in-Case-command/m-p/27831#M5450</guid>
      <dc:creator>ad_no1</dc:creator>
      <dc:date>2013-05-08T16:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: Rex in Case command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-in-Case-command/m-p/27832#M5451</link>
      <description>&lt;P&gt;You can't put just any command into an eval statement - you can only use the &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions"&gt;eval functions&lt;/A&gt;. &lt;/P&gt;

&lt;P&gt;Also, you seem to be trying to do this in an "if then else" in a procedural kind of way. You need to rethink that with Splunk.&lt;/P&gt;

&lt;P&gt;Try this instead&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=_raw "customers:\s+(?&amp;lt;product_code&amp;gt;.*?)\("
| rex field=_raw "pro_codes were not mapped:\s+(?&amp;lt;product_code&amp;gt;.*?)\;"
| rex field=_raw "pro_codes\s+= \s+(?&amp;lt;product_code&amp;gt;.*?)\)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Splunk will only create the &lt;CODE&gt;product_code&lt;/CODE&gt; field when the event matches the regular expression; each event will (hopefully) only match one of them.&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2013 01:11:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-in-Case-command/m-p/27832#M5451</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-05-09T01:11:51Z</dc:date>
    </item>
  </channel>
</rss>

