<?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: Splunk DB Connect - Output to MSSQL with decimal values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-DB-Connect-Output-to-MSSQL-with-decimal-values/m-p/30821#M178048</link>
    <description>&lt;P&gt;Thanks for the response.&lt;/P&gt;

&lt;P&gt;The admins changed it to a real and it appears to work now.&lt;BR /&gt;
&lt;A href="http://imgur.com/a/02b00"&gt;http://imgur.com/a/02b00&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I am aware dboutput.conf is not fully supported as of yet but some an example of how to use it would be excellent if you could provide it.&lt;/P&gt;</description>
    <pubDate>Wed, 05 Jun 2013 04:42:40 GMT</pubDate>
    <dc:creator>phoenixdigital</dc:creator>
    <dc:date>2013-06-05T04:42:40Z</dc:date>
    <item>
      <title>Splunk DB Connect - Output to MSSQL with decimal values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-DB-Connect-Output-to-MSSQL-with-decimal-values/m-p/30819#M178046</link>
      <description>&lt;P&gt;I am aware this feature is not officially supported but thought I would post this question here.&lt;/P&gt;

&lt;P&gt;We have a MSSQL table with the following format&lt;BR /&gt;
datetime time&lt;BR /&gt;
string identifier&lt;BR /&gt;
numeric thisDecimalValue (with 4 decimal places)&lt;/P&gt;

&lt;P&gt;This screenshot shows how Splunk DB Connect sees the table &lt;BR /&gt;
&lt;A href="http://imgur.com/tcG3kQe"&gt;http://imgur.com/tcG3kQe&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Now this search/insert&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="this" earliest=-1m | eval time = _time | eval thisDecimalValue = round(thisDecimalValue,2) | fields time, identifier, thisDecimalValue  | dboutput type=insert database="MSSQL Instance" table="Splunk.outputTable" time, identifier, thisDecimalValue 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Ends up with the error&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;command="dboutput", Unexpected error while performing dboutput: java.sql.SQLException: Cannot convert value "0.00" to required datatype LONG
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;We have tried with MSQQL numeric and decimal for the field typebut still no joy. Getting the admins to change the field type to float but they have not done this yet.&lt;/P&gt;

&lt;P&gt;A colleague suggested using the dboutput.conf to create a custom SQL statement.&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/DBX/latest/DeployDBX/dboutputspec"&gt;http://docs.splunk.com/Documentation/DBX/latest/DeployDBX/dboutputspec&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Can someone please shed more light on how you formulate the sql.insert string to use the results from the Splunk search?&lt;/P&gt;

&lt;P&gt;How is it triggered as well once you have created these stanzas?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2013 05:07:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-DB-Connect-Output-to-MSSQL-with-decimal-values/m-p/30819#M178046</guid>
      <dc:creator>phoenixdigital</dc:creator>
      <dc:date>2013-05-13T05:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk DB Connect - Output to MSSQL with decimal values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-DB-Connect-Output-to-MSSQL-with-decimal-values/m-p/30820#M178047</link>
      <description>&lt;P&gt;Have you tried the float datatype? Did it work?&lt;/P&gt;

&lt;P&gt;Your screenshot of dbinfo doesn't show the full definition of the decimal datatype - it is missing the precision and scale.&lt;/P&gt;

&lt;P&gt;According to MS SQL, &lt;A href="http://msdn.microsoft.com/en-us/library/ms187746.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms187746.aspx&lt;/A&gt;, both decimal and numeric default to allowing 0 digits to the right of the decimal point ("the default scale is 0"). So it might not be possible to convert.&lt;/P&gt;

&lt;P&gt;Using dboutput.conf is not really an option while this feature is in beta.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2013 22:24:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-DB-Connect-Output-to-MSSQL-with-decimal-values/m-p/30820#M178047</guid>
      <dc:creator>Dan</dc:creator>
      <dc:date>2013-06-03T22:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk DB Connect - Output to MSSQL with decimal values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-DB-Connect-Output-to-MSSQL-with-decimal-values/m-p/30821#M178048</link>
      <description>&lt;P&gt;Thanks for the response.&lt;/P&gt;

&lt;P&gt;The admins changed it to a real and it appears to work now.&lt;BR /&gt;
&lt;A href="http://imgur.com/a/02b00"&gt;http://imgur.com/a/02b00&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I am aware dboutput.conf is not fully supported as of yet but some an example of how to use it would be excellent if you could provide it.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2013 04:42:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-DB-Connect-Output-to-MSSQL-with-decimal-values/m-p/30821#M178048</guid>
      <dc:creator>phoenixdigital</dc:creator>
      <dc:date>2013-06-05T04:42:40Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk DB Connect - Output to MSSQL with decimal values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-DB-Connect-Output-to-MSSQL-with-decimal-values/m-p/30822#M178049</link>
      <description>&lt;P&gt;dboutput.conf is not supported in all versions of DB Connect 1.x. Trying to invoke &lt;CODE&gt;| dboutput &amp;lt;stanza name&amp;gt;&lt;/CODE&gt; will throw a NotImplementedException.&lt;/P&gt;

&lt;P&gt;&lt;STRIKE&gt;If you want to manually generate the sql, you can either set &lt;CODE&gt;sql&lt;/CODE&gt;, or &lt;CODE&gt;sql.insert and sql.update&lt;/CODE&gt;. Make sure to also set &lt;CODE&gt;advanced=true&lt;/CODE&gt;.&lt;BR /&gt;
For the sql syntax, one hint is to look at what the debug logging shows about the auto-generated query. For an example, see: &lt;A href="http://splunk-base.splunk.com/answers/88599/dboutput-bug-updating-mysql"&gt;http://splunk-base.splunk.com/answers/88599/dboutput-bug-updating-mysql&lt;/A&gt;&lt;/STRIKE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;UPDATE mytable SET ip=$ip$, NetAddress=$NetAddress$, ComputerName=$ComputerName$, Manufacturer=$Manufacturer$, Model=$Model$, mac=$mac$, IPAddress=$IPAddress$ WHERE ip = $ip$&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;So in your SQL you can reference any field in the search results by using $fieldname$.&lt;/P&gt;

&lt;P&gt;To invoke the config is fairly simple, just use &lt;CODE&gt;| dboutput &amp;lt;stanza name&amp;gt;&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2013 16:56:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-DB-Connect-Output-to-MSSQL-with-decimal-values/m-p/30822#M178049</guid>
      <dc:creator>Dan</dc:creator>
      <dc:date>2013-06-05T16:56:21Z</dc:date>
    </item>
  </channel>
</rss>

