<?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>question Re: ODBC driver for Hive - OdbcCommand not working if parameter is Null in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/ODBC-driver-for-Hive-OdbcCommand-not-working-if-parameter-is/m-p/58412#M64748</link>
    <description>&lt;P&gt;I realized today, after browsing many google results, that it is illicit to use a "null" value as a parameter of&amp;nbsp;a where clause.&lt;/P&gt;&lt;BLOCKQUOTE&gt;Because null is considered to be unknown, two null values compared to each other are not considered to be equal. In expressions using arithmetic operators, if any of the operands is null, the result is null as well.&lt;/BLOCKQUOTE&gt;&lt;P&gt;Details can be found here : &lt;A href="https://stackoverflow.com/questions/36992184/sqlcommand-createparameter-value-dbnull-value-not-returning-results" target="_blank"&gt;https://stackoverflow.com/questions/36992184/sqlcommand-createparameter-value-dbnull-value-not-returning-results&lt;/A&gt;&lt;/P&gt;&lt;P&gt;So it was obvious that my simple C# sample would not work and it had actually nothing to do with the Cloudera ODBC driver.&lt;/P&gt;</description>
    <pubDate>Thu, 03 Aug 2017 16:58:56 GMT</pubDate>
    <dc:creator>jazzman71</dc:creator>
    <dc:date>2017-08-03T16:58:56Z</dc:date>
    <item>
      <title>ODBC driver for Hive - OdbcCommand not working if parameter is Null</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/ODBC-driver-for-Hive-OdbcCommand-not-working-if-parameter-is/m-p/57271#M64745</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wrote the simple C# sample below that uses OdbcCommand and OdbcParameter :&lt;/P&gt;&lt;P&gt;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;string connectionString = "DRIVER={Cloudera ODBC Driver for Apache Hive};HOST=myserver;PORT=10000;DB=default;UID=me;PWD=mypwd";&lt;/P&gt;&lt;P&gt;string queryString = "select * from my_table where foo=? AND bar=?";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using (OdbcConnection connection =&lt;/P&gt;&lt;P&gt;new OdbcConnection(connectionString))&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OdbcCommand command = new OdbcCommand(queryString, connection);&lt;/P&gt;&lt;P&gt;// Open the connection and execute the select command.&lt;/P&gt;&lt;P&gt;try&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;connection.Open();&lt;/P&gt;&lt;P&gt;OdbcParameter param1 = new OdbcParameter("@p1", "hadoop");&lt;/P&gt;&lt;P&gt;OdbcParameter param2 = new OdbcParameter("@p2", DBNull.Value);&lt;/P&gt;&lt;P&gt;&amp;nbsp;command.Parameters.Add(param1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;command.Parameters.Add(param2);&lt;/P&gt;&lt;P&gt;OdbcDataReader reader = command.ExecuteReader();&lt;/P&gt;&lt;P&gt;if (reader.HasRows) {&lt;/P&gt;&lt;P&gt;Console.WriteLine("Hurray");&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;catch (Exception ex)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;Console.WriteLine(ex.Message);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;// The connection is automatically closed when the&lt;/P&gt;&lt;P&gt;// code exits the using block.&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Although I am expecting to find some results, the query does not return any rows. Obviously, if I change the bar=? parameter by "bar is null", I get the results that I am expecting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It looks like using an OdbcParameter with a DBNull.Value value is not working with Cloudera ODBC...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 11:54:58 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/ODBC-driver-for-Hive-OdbcCommand-not-working-if-parameter-is/m-p/57271#M64745</guid>
      <dc:creator>jazzman71</dc:creator>
      <dc:date>2022-09-16T11:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: ODBC driver for Hive - OdbcCommand not working if parameter is Null</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/ODBC-driver-for-Hive-OdbcCommand-not-working-if-parameter-is/m-p/57293#M64746</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/22909"&gt;@jazzman71&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think there could be two possibilities for this issue&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Posibility 1. As you said, this might be an issue with odbc command with parameter&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Posibility 2.&amp;nbsp;Hive is not recognizing the argument as '?' from your code. May be you can try with different argument&amp;nbsp; options as mentioned in this link&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/12464636/how-to-set-variables-in-hive-scripts" target="_blank"&gt;https://stackoverflow.com/questions/12464636/how-to-set-variables-in-hive-scripts&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 19:10:07 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/ODBC-driver-for-Hive-OdbcCommand-not-working-if-parameter-is/m-p/57293#M64746</guid>
      <dc:creator>saranvisa</dc:creator>
      <dc:date>2017-07-12T19:10:07Z</dc:date>
    </item>
    <item>
      <title>Re: ODBC driver for Hive - OdbcCommand not working if parameter is Null</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/ODBC-driver-for-Hive-OdbcCommand-not-working-if-parameter-is/m-p/57490#M64747</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;for your answer, but&amp;nbsp;I do not see the relationship&amp;nbsp;between ODBC and&amp;nbsp;Hive scripts...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would be interesting to have the feedback of someone who did use the Cloudera ODBC Driver with OdbcParameter and&amp;nbsp;DBNull.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 08:03:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/ODBC-driver-for-Hive-OdbcCommand-not-working-if-parameter-is/m-p/57490#M64747</guid>
      <dc:creator>jazzman71</dc:creator>
      <dc:date>2017-07-17T08:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: ODBC driver for Hive - OdbcCommand not working if parameter is Null</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/ODBC-driver-for-Hive-OdbcCommand-not-working-if-parameter-is/m-p/58412#M64748</link>
      <description>&lt;P&gt;I realized today, after browsing many google results, that it is illicit to use a "null" value as a parameter of&amp;nbsp;a where clause.&lt;/P&gt;&lt;BLOCKQUOTE&gt;Because null is considered to be unknown, two null values compared to each other are not considered to be equal. In expressions using arithmetic operators, if any of the operands is null, the result is null as well.&lt;/BLOCKQUOTE&gt;&lt;P&gt;Details can be found here : &lt;A href="https://stackoverflow.com/questions/36992184/sqlcommand-createparameter-value-dbnull-value-not-returning-results" target="_blank"&gt;https://stackoverflow.com/questions/36992184/sqlcommand-createparameter-value-dbnull-value-not-returning-results&lt;/A&gt;&lt;/P&gt;&lt;P&gt;So it was obvious that my simple C# sample would not work and it had actually nothing to do with the Cloudera ODBC driver.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2017 16:58:56 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/ODBC-driver-for-Hive-OdbcCommand-not-working-if-parameter-is/m-p/58412#M64748</guid>
      <dc:creator>jazzman71</dc:creator>
      <dc:date>2017-08-03T16:58:56Z</dc:date>
    </item>
  </channel>
</rss>

