<?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: Excute sql statement on splunk db connect in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Excute-sql-statement-on-splunk-db-connect/m-p/370014#M175052</link>
    <description>&lt;P&gt;Your query includes bind variables which need values. That's what the "Missing IN or OUT parameter" error means. There's an example of building a parameterized query here &lt;A href="http://docs.splunk.com/Documentation/DBX/3.0.2/DeployDBX/Commands" target="_blank"&gt;http://docs.splunk.com/Documentation/DBX/3.0.2/DeployDBX/Commands&lt;/A&gt;. It should look something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;dbxquery query="select * from actor where actor_id &amp;gt; ? and actor_name = ?" connection="mysql" params="3,BOB"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You'll have to replace every ":p_" parameter (e.g. :p_to_date, :p_ledger_id, etc.) with a question mark and list out every occurrence of every value, in order. Given the size of your query that might be tricky. At the very least I believe that you will have to build a custom dashboard/report interface with fields to provide those values.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 13:21:23 GMT</pubDate>
    <dc:creator>pmdba</dc:creator>
    <dc:date>2020-09-29T13:21:23Z</dc:date>
    <item>
      <title>Excute sql statement on splunk db connect</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Excute-sql-statement-on-splunk-db-connect/m-p/370013#M175051</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;am connected to oracle database &amp;amp; am trying to get data from it using splunk dbconnect,&lt;BR /&gt;
amd trying to excute the below statement but it give error "Invalid Query&lt;BR /&gt;
java.sql.SQLException: Missing IN or OUT parameter at index:: 1" while it working fine from oracle database, can any one provide me a solution for this issue? &lt;/P&gt;

&lt;P&gt;SELECT  concatenated_segments "Account",account_desc "Account Desc"&lt;BR /&gt;
, round(sum(accounted_dr),2) "Dr",round(sum(accounted_cr),2) "Cr"&lt;BR /&gt;
,&lt;/P&gt;

&lt;P&gt;case &lt;BR /&gt;
when concatenated_segments=(select '01'|| '.' || rh.loss_SEGMENT2|| '.' || rh.loss_SEGMENT3|| '.' || rh.loss_SEGMENT4|| '.' || rh.loss_SEGMENT5 loss&lt;/P&gt;

&lt;P&gt;from GL_REVALUATIONS rh&lt;BR /&gt;
 where rh.REVALUATION_ID=:REV11000&lt;BR /&gt;
 and rh.CHART_OF_ACCOUNTS_ID=:P_COA_ID)&lt;BR /&gt;
then  round(sum(rev_dr),2)+(-1*D_GET_REVALUATION_TB_XLA(nvl(:p_to_date,sysdate),:p_ledger_id,:P_COA_ID,:p_from_account,:p_to_account,:REV11000,(select CONVERSION_RATE_TYPE from GL_REVALUATIONS where REVALUATION_ID=:REV11000)))&lt;/P&gt;

&lt;P&gt;else round(sum(rev_dr),2)&lt;/P&gt;

&lt;P&gt;end "rev_Dr",&lt;/P&gt;

&lt;P&gt;else round(sum(rev_cr),2) &lt;BR /&gt;
 end*/&lt;BR /&gt;
   round(sum(rev_cr),2)  "rev_Cr"&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;FROM (
      --XLA
      SELECT 2 seq, cc.concatenated_segments,
             cc.segment2 || '.' || cc.segment3 || '.'
             || cc.segment4 jaccount,
                xxseg_descr.segment_desc
                                    ('SEGMENT2',
                                     cc.segment2,
                                     cc.chart_of_accounts_id
                                    )
             || '.'
             || xxseg_descr.segment_desc ('SEGMENT3',
                                          cc.segment3,
                                          cc.chart_of_accounts_id
                                         )
             || '.'
             || xxseg_descr.segment_desc ('SEGMENT4',
                                          cc.segment4,
                                          cc.segment3,
                                          cc.chart_of_accounts_id
                                         ) account_desc,
             l.accounting_date, ev.transaction_date,
             TO_CHAR (en.transaction_number) transaction_number,
             h.je_category_name doc_type, pp.je_source_name jsource,
             h.description, l.description line_desc, l.currency_code,
             l.currency_conversion_rate,
             NVL (l.entered_dr, -l.entered_cr) amount, 0 open_dr,
             0 open_cr
             , l.accounted_dr, l.accounted_cr
              ,0 open_cur_cr,0 open_cur_dr
              ,l.ENTERED_CR,l.ENTERED_DR
                      ,case 
             when  cc.concatenated_segments in 
             (select distinct cc1.CONCATENATED_SEGMENTS
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;from GL_REVALUATIONS rh,&lt;BR /&gt;
 GL_REVAL_ACCOUNT_RANGES rl&lt;BR /&gt;
 , gl_code_combinations_kfv cc1&lt;BR /&gt;
 where &lt;BR /&gt;
 rh.REVALUATION_ID=rl.REVALUATION_ID&lt;/P&gt;

&lt;P&gt;and rl.REVALUATION_ID=:REV11000&lt;BR /&gt;
 and  cc1.ENABLED_FLAG='Y'&lt;BR /&gt;
 and cc1.CHART_OF_ACCOUNTS_ID=:P_COA_ID&lt;BR /&gt;
and cc1.segment3 between rl.SEGMENT3_LOW and  rl.SEGMENT3_HIGH&lt;BR /&gt;
and cc1.segment4 between rl.SEGMENT4_LOW and  rl.SEGMENT4_HIGH&lt;BR /&gt;
and cc1.segment2 between rl.SEGMENT2_LOW and  rl.SEGMENT2_HIGH&lt;BR /&gt;
and cc1.segment1 between rl.SEGMENT1_LOW and  rl.SEGMENT1_HIGH&lt;BR /&gt;
and cc1.segment5 between rl.SEGMENT5_LOW and  rl.SEGMENT5_HIGH &lt;BR /&gt;
and cc1.ENABLED_FLAG='Y'&lt;BR /&gt;
AND (    cc1.concatenated_segments &amp;gt;= :p_from_account&lt;BR /&gt;
AND cc1.concatenated_segments &amp;lt;= :p_to_account&lt;BR /&gt;
))&lt;BR /&gt;
 then  ENTERED_DR*(D_get_rate(l.currency_code,to_char(:p_to_date,'DD-MM-YYYY'),(select CONVERSION_RATE_TYPE from GL_REVALUATIONS where REVALUATION_ID=:REV11000)))&lt;BR /&gt;
 else accounted_dr&lt;BR /&gt;
                 end rev_dr&lt;BR /&gt;
                           ,case &lt;BR /&gt;
                 when  cc.concatenated_segments in &lt;BR /&gt;
                 (select distinct cc1.CONCATENATED_SEGMENTS&lt;/P&gt;

&lt;P&gt;from GL_REVALUATIONS rh,&lt;BR /&gt;
 GL_REVAL_ACCOUNT_RANGES rl&lt;BR /&gt;
 , gl_code_combinations_kfv cc1&lt;BR /&gt;
 where &lt;BR /&gt;
 rh.REVALUATION_ID=rl.REVALUATION_ID&lt;/P&gt;

&lt;P&gt;and rl.REVALUATION_ID=:REV11000&lt;BR /&gt;
 and  cc1.ENABLED_FLAG='Y'&lt;BR /&gt;
 and cc1.CHART_OF_ACCOUNTS_ID=:P_COA_ID&lt;BR /&gt;
and cc1.segment3 between rl.SEGMENT3_LOW and  rl.SEGMENT3_HIGH&lt;BR /&gt;
and cc1.segment4 between rl.SEGMENT4_LOW and  rl.SEGMENT4_HIGH&lt;BR /&gt;
and cc1.segment2 between rl.SEGMENT2_LOW and  rl.SEGMENT2_HIGH&lt;BR /&gt;
and cc1.segment1 between rl.SEGMENT1_LOW and  rl.SEGMENT1_HIGH&lt;BR /&gt;
and cc1.segment5 between rl.SEGMENT5_LOW and  rl.SEGMENT5_HIGH &lt;BR /&gt;
and cc1.ENABLED_FLAG='Y'&lt;BR /&gt;
AND (    cc1.concatenated_segments &amp;gt;= :p_from_account&lt;BR /&gt;
AND cc1.concatenated_segments &amp;lt;= :p_to_account&lt;BR /&gt;
))&lt;BR /&gt;
 then  ENTERED_cR*(D_get_rate(l.currency_code,to_char(:p_to_date,'DD-MM-YYYY'),(select CONVERSION_RATE_TYPE from GL_REVALUATIONS where REVALUATION_ID=:REV11000)))&lt;BR /&gt;
 else accounted_cr&lt;BR /&gt;
                 end rev_cr &lt;BR /&gt;
                 ,(D_get_rate(l.currency_code,to_char(:p_to_date,'DD-MM-YYYY'),(select CONVERSION_RATE_TYPE from GL_REVALUATIONS where REVALUATION_ID=:REV11000))) rt&lt;BR /&gt;
            FROM xla_ae_headers h,&lt;BR /&gt;
                 xla_ae_lines l,&lt;BR /&gt;
                 gl_code_combinations_kfv cc,&lt;BR /&gt;
                 xla_subledgers pp,&lt;BR /&gt;
                 xla_events ev,&lt;BR /&gt;
                 xla.xla_transaction_entities en&lt;BR /&gt;
           WHERE h.ae_header_id = l.ae_header_id&lt;BR /&gt;
             AND h.ledger_id = l.ledger_id&lt;BR /&gt;
             AND l.code_combination_id = cc.code_combination_id&lt;BR /&gt;
             AND pp.application_id = h.application_id&lt;BR /&gt;
             AND ev.event_id = h.event_id&lt;BR /&gt;
             AND ev.application_id = h.application_id&lt;BR /&gt;
             AND h.entity_id = en.entity_id&lt;BR /&gt;
             AND NVL (h.zero_amount_flag, 'N') &amp;lt;&amp;gt; 'Y'&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;         AND l.ledger_id = :p_ledger_id
         AND (h.accounting_date &amp;gt;= :p_from_date OR :p_from_date IS NULL)
         AND (h.accounting_date &amp;lt;= :p_to_date OR :p_to_date IS NULL)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;AND (cc.concatenated_segments &amp;gt;= :p_from_account&lt;BR /&gt;
AND cc.concatenated_segments &amp;lt;= :p_to_account)&lt;BR /&gt;
          UNION ALL&lt;BR /&gt;
--GL&lt;BR /&gt;&lt;BR /&gt;
 SELECT 4 seq, cc.concatenated_segments,&lt;BR /&gt;
                 cc.segment2 || '.' || cc.segment3 || '.'&lt;BR /&gt;
                 || cc.segment4 jaccount,&lt;BR /&gt;
                    xxseg_descr.segment_desc&lt;BR /&gt;
                                        ('SEGMENT2',&lt;BR /&gt;
                                         cc.segment2,&lt;BR /&gt;
                                         cc.chart_of_accounts_id&lt;BR /&gt;
                                        )&lt;BR /&gt;
                 || '.'&lt;BR /&gt;
                 || xxseg_descr.segment_desc ('SEGMENT3',&lt;BR /&gt;
                                              cc.segment3,&lt;BR /&gt;
                                              cc.chart_of_accounts_id&lt;BR /&gt;
                                             )&lt;BR /&gt;
                 || '.'&lt;BR /&gt;
                 || xxseg_descr.segment_desc ('SEGMENT4',&lt;BR /&gt;
                                              cc.segment4,&lt;BR /&gt;
                                              cc.segment3,&lt;BR /&gt;
                                              cc.chart_of_accounts_id&lt;BR /&gt;
                                             ) account_desc,&lt;BR /&gt;
                 jl.effective_date, jh.default_effective_date doc_date,&lt;BR /&gt;
                 NVL (TO_CHAR (jh.doc_sequence_value),&lt;BR /&gt;
                      jl.description&lt;BR /&gt;
                     ) doc_number,&lt;BR /&gt;
                 jh.je_category jcategory, 'GL' jsource,&lt;BR /&gt;
                 jh.description h_desc, jl.description line_desc,&lt;BR /&gt;
                 jh.currency_code curr, jh.currency_conversion_rate rate,&lt;BR /&gt;
                 NVL (jl.entered_dr, -jl.entered_cr) entered&lt;BR /&gt;
                 , 0 open_dr,0 open_cr&lt;BR /&gt;
                 , jl.accounted_dr acconted_dr, jl.accounted_cr&lt;BR /&gt;
                 ,jl.ENTERED_CR,jl.ENTERED_DR &lt;BR /&gt;
                 ,0 open_cur_cr,0 open_cur_dr&lt;BR /&gt;
                         ,case when jh.je_source='Revaluation'&lt;BR /&gt;
                         then 0&lt;BR /&gt;
                 when  cc.concatenated_segments in &lt;BR /&gt;
                 (select distinct cc1.CONCATENATED_SEGMENTS&lt;/P&gt;

&lt;P&gt;from GL_REVALUATIONS rh,&lt;BR /&gt;
 GL_REVAL_ACCOUNT_RANGES rl&lt;BR /&gt;
 , gl_code_combinations_kfv cc1&lt;BR /&gt;
 where &lt;BR /&gt;
 rh.REVALUATION_ID=rl.REVALUATION_ID&lt;/P&gt;

&lt;P&gt;and rl.REVALUATION_ID=:REV11000&lt;BR /&gt;
 and  cc1.ENABLED_FLAG='Y'&lt;BR /&gt;
 and cc1.CHART_OF_ACCOUNTS_ID=:P_COA_ID&lt;BR /&gt;
and cc1.segment3 between rl.SEGMENT3_LOW and  rl.SEGMENT3_HIGH&lt;BR /&gt;
and cc1.segment4 between rl.SEGMENT4_LOW and  rl.SEGMENT4_HIGH&lt;BR /&gt;
and cc1.segment2 between rl.SEGMENT2_LOW and  rl.SEGMENT2_HIGH&lt;BR /&gt;
and cc1.segment1 between rl.SEGMENT1_LOW and  rl.SEGMENT1_HIGH&lt;BR /&gt;
and cc1.segment5 between rl.SEGMENT5_LOW and  rl.SEGMENT5_HIGH &lt;BR /&gt;
and cc1.ENABLED_FLAG='Y'&lt;BR /&gt;
AND (    cc1.concatenated_segments &amp;gt;= :p_from_account&lt;BR /&gt;
AND cc1.concatenated_segments &amp;lt;= :p_to_account&lt;BR /&gt;
)&lt;BR /&gt;
)&lt;BR /&gt;
 then  ENTERED_DR*(D_get_rate(jh.currency_code,to_char(:p_to_date,'DD-MM-YYYY'),(select CONVERSION_RATE_TYPE from GL_REVALUATIONS where REVALUATION_ID=:REV11000)))&lt;BR /&gt;
 else accounted_dr&lt;BR /&gt;
                 end rev_dr&lt;BR /&gt;
                           ,case when jh.je_source='Revaluation'&lt;BR /&gt;
                         then 0&lt;BR /&gt;
                 when  cc.concatenated_segments in &lt;BR /&gt;
                 (select distinct cc1.CONCATENATED_SEGMENTS&lt;/P&gt;

&lt;P&gt;from GL_REVALUATIONS rh,&lt;BR /&gt;
 GL_REVAL_ACCOUNT_RANGES rl&lt;BR /&gt;
 , gl_code_combinations_kfv cc1&lt;BR /&gt;
 where &lt;BR /&gt;
 rh.REVALUATION_ID=rl.REVALUATION_ID&lt;/P&gt;

&lt;P&gt;and rl.REVALUATION_ID=:REV11000&lt;BR /&gt;
 and  cc1.ENABLED_FLAG='Y'&lt;BR /&gt;
 and cc1.CHART_OF_ACCOUNTS_ID=:P_COA_ID&lt;BR /&gt;
and cc1.segment3 between rl.SEGMENT3_LOW and  rl.SEGMENT3_HIGH&lt;BR /&gt;
and cc1.segment4 between rl.SEGMENT4_LOW and  rl.SEGMENT4_HIGH&lt;BR /&gt;
and cc1.segment2 between rl.SEGMENT2_LOW and  rl.SEGMENT2_HIGH&lt;BR /&gt;
and cc1.segment1 between rl.SEGMENT1_LOW and  rl.SEGMENT1_HIGH&lt;BR /&gt;
and cc1.segment5 between rl.SEGMENT5_LOW and  rl.SEGMENT5_HIGH &lt;BR /&gt;
and cc1.ENABLED_FLAG='Y'&lt;BR /&gt;
AND (    cc1.concatenated_segments &amp;gt;= :p_from_account&lt;BR /&gt;
AND cc1.concatenated_segments &amp;lt;= :p_to_account&lt;BR /&gt;
))&lt;BR /&gt;
 then  ENTERED_cR*(D_get_rate(jh.currency_code,to_char(:p_to_date,'DD-MM-YYYY'),(select CONVERSION_RATE_TYPE from GL_REVALUATIONS where REVALUATION_ID=:REV11000)))&lt;BR /&gt;
 else accounted_cr&lt;BR /&gt;
  end rev_cr ,(D_get_rate(jh.currency_code,to_char(:p_to_date,'DD-MM-YYYY'),(select CONVERSION_RATE_TYPE from GL_REVALUATIONS where REVALUATION_ID=:REV11000))) rt&lt;BR /&gt;
            FROM gl_je_headers jh, gl_je_lines jl,&lt;BR /&gt;
                 gl_code_combinations_kfv cc&lt;BR /&gt;
           WHERE jh.je_header_id = jl.je_header_id&lt;BR /&gt;
             AND (   jh.je_source IN ('Manual', '1', 'Revaluation','Closing Journal')&lt;BR /&gt;
                  OR (    jh.je_source NOT IN ('Manual', '1', 'Revaluation','Closing Journal')&lt;BR /&gt;
                      AND jh.reversed_je_header_id IS NOT NULL&lt;BR /&gt;
                     )&lt;BR /&gt;
                 )&lt;BR /&gt;
             AND cc.code_combination_id = jl.code_combination_id&lt;/P&gt;

&lt;P&gt;AND (cc.concatenated_segments &amp;gt;= :p_from_account&lt;BR /&gt;
AND cc.concatenated_segments &amp;lt;= :p_to_account)&lt;BR /&gt;
             AND jh.ledger_id = :p_ledger_id&lt;BR /&gt;
             AND (jl.effective_date &amp;gt;= :p_from_date OR :p_from_date IS NULL)&lt;BR /&gt;
             AND (jl.effective_date &amp;lt;= :p_to_date OR :p_to_date IS NULL))&lt;BR /&gt;
   WHERE (currency_code = :p_curr OR :p_curr IS NULL)&lt;BR /&gt;
     AND (jsource = :p_source OR :p_source IS NULL)&lt;BR /&gt;
     AND (    concatenated_segments &amp;gt;= :p_from_account&lt;BR /&gt;
          AND concatenated_segments &amp;lt;= :p_to_account&lt;BR /&gt;
         )&lt;BR /&gt;
     AND (transaction_number = :p_trx_number OR :p_trx_number IS NULL)&lt;BR /&gt;
     AND (amount = :p_amount OR :p_amount IS NULL)&lt;BR /&gt;
     group by concatenated_segments,account_desc &lt;/P&gt;

&lt;P&gt;ORDER BY concatenated_segments &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:19:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Excute-sql-statement-on-splunk-db-connect/m-p/370013#M175051</guid>
      <dc:creator>MAShawky</dc:creator>
      <dc:date>2020-09-29T13:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: Excute sql statement on splunk db connect</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Excute-sql-statement-on-splunk-db-connect/m-p/370014#M175052</link>
      <description>&lt;P&gt;Your query includes bind variables which need values. That's what the "Missing IN or OUT parameter" error means. There's an example of building a parameterized query here &lt;A href="http://docs.splunk.com/Documentation/DBX/3.0.2/DeployDBX/Commands" target="_blank"&gt;http://docs.splunk.com/Documentation/DBX/3.0.2/DeployDBX/Commands&lt;/A&gt;. It should look something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;dbxquery query="select * from actor where actor_id &amp;gt; ? and actor_name = ?" connection="mysql" params="3,BOB"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You'll have to replace every ":p_" parameter (e.g. :p_to_date, :p_ledger_id, etc.) with a question mark and list out every occurrence of every value, in order. Given the size of your query that might be tricky. At the very least I believe that you will have to build a custom dashboard/report interface with fields to provide those values.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:21:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Excute-sql-statement-on-splunk-db-connect/m-p/370014#M175052</guid>
      <dc:creator>pmdba</dc:creator>
      <dc:date>2020-09-29T13:21:23Z</dc:date>
    </item>
  </channel>
</rss>

