{"id":54010,"date":"2022-04-01T13:57:18","date_gmt":"2022-04-01T13:57:18","guid":{"rendered":"https:\/\/merikebi.warrenmyers.com\/?p=54010"},"modified":"2022-04-01T13:57:18","modified_gmt":"2022-04-01T13:57:18","slug":"answer-by-warren-for-splunk-message-value-a-string-literal-was-expected","status":"publish","type":"post","link":"https:\/\/merikebi.warrenmyers.com\/?p=54010","title":{"rendered":"Answer by warren for SPLUNK : .Message.value()]: A string literal was expected"},"content":{"rendered":"<p>Per the <a href=\"https:\/\/docs.splunk.com\/Documentation\/DBX\/latest\/DeployDBX\/Commands\" rel=\"nofollow noreferrer\">docs<\/a>, the fact you have multiple types of quote marks is most likely causing the error you&#8217;re seeing.<\/p>\n<p>Your excised query:<\/p>\n<pre><code>(select top 1 a.Message.value ('(\/\/Transaction[@transactionID=sql:column(&quot;t.Txn_Ref_Num&quot;)]\/LifeSupportNotification\/LifeSupportData\/Status)[1]', 'varchar(50)') \n<\/code><\/pre>\n<p>Note you have both single (<code>'<\/code>) <em>and<\/em> double (<code>&quot;<\/code>) quotes in the string.<\/p>\n<p>Per the <code>dbxquery<\/code> page on Docs.Splunk, the query you send is supposed to be encased in double quotes:<\/p>\n<blockquote>\n<p><strong>query<\/strong><br \/>\n<strong>Syntax<\/strong>: <code>query=&lt;string&gt;<\/code><br \/>\n<strong>Description<\/strong>: A SQL query. You can also use a URL-encoded SQL query, but you must percent-encode all spaces (%20).<\/p>\n<\/blockquote>\n<p>And one of the examples shown:<\/p>\n<blockquote>\n<p><code>dbxquery query=&quot;select * from actor where actor_id &gt; ? and actor_name = ?&quot; connection=&quot;mysql&quot; params=&quot;3,BOB&quot;<\/code><\/p>\n<\/blockquote>\n<p>The two other examples shown:<\/p>\n<blockquote>\n<p><code>| dbxquery query=&quot;SELECT actor_id, first_name as fname, last_name as lname, last_update FROM actor&quot; connection=&quot;mySQL&quot; <\/code><\/p>\n<\/blockquote>\n<blockquote>\n<p><code>| dbxquery query=&quot;SELECT actor_id, first_name as fname, last_name as lname, last_update FROM actor&quot; connection=&quot;mySQL&quot; maxrows=100<\/code><\/p>\n<\/blockquote>\n<p>from User warren &#8211; Stack Overflow https:\/\/stackoverflow.com\/questions\/71703393\/splunk-message-value-a-string-literal-was-expected\/71708029#71708029<br \/>\nvia <a href=\"https:\/\/ifttt.com\/?ref=da&#038;site=wordpress\">IFTTT<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Per the docs, the fact you have multiple types of quote marks is most likely causing the error you&#8217;re seeing. Your excised query: (select top 1 a.Message.value (&#8216;(\/\/Transaction[@transactionID=sql:column(&quot;t.Txn_Ref_Num&quot;)]\/LifeSupportNotification\/LifeSupportData\/Status)[1]&#8217;, &#8216;varchar(50)&#8217;) Note you have both single (&#8216;) and double (&quot;) quotes in the string. Per the dbxquery page on Docs.Splunk, the query you send is supposed to &hellip;<br \/><a href=\"https:\/\/merikebi.warrenmyers.com\/?p=54010\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">Answer by warren for SPLUNK : .Message.value()]: A string literal was expected<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[991],"keyring_services":[],"class_list":["post-54010","post","type-post","status-publish","format-standard","hentry","category-blih","tag-stackexchange"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/54010","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=54010"}],"version-history":[{"count":1,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/54010\/revisions"}],"predecessor-version":[{"id":54011,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/54010\/revisions\/54011"}],"wp:attachment":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=54010"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=54010"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=54010"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fkeyring_services&post=54010"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}