Wanting to run a query in a C# application against hive.
OdbcCommand cmd = conn.CreateCommand(); cmd.CommandText = "SELECT * FROM user WHERE id = ?"; cmd.Parameters.Add("?id", OdbcType.Int).Value = 4; OdbcDataReader reader = cmd.ExecuteReader();
But end up getting an error from the ODBC driver
ERROR [HY000] [Hortonworks][HiveODBC] (80) Syntax or semantic analysis error thrown in server while execurint query. Error message from server: Error while compiling statement: FAILED: ParseException line 1:42 cannot recognize input near '?' '<EOF>' in expression specification
The issue seems to be with the cmd.Parameters.Add("?id",OdbcType.Int).Value=4; you may want to try this one instead and see if this helps
cmd.Parameters.Add("@id", OdbcType.Int).Value = 4;
I'm no c# expert but seems like this could be the issue.
@mbalakrishnan I'll try that but that does look to be just a different method of adding parameters to the OdbcCommand object. At this point I am thinking this is an issue with the Hive ODBC driver itself. I cannot find any documentation related to this subject for the Hive ODBC and the things I found people are having the same issue.
@Giovanny As this question is old, I would suggest starting a new thread for your issue. This would allow you to also provide further details about your unique environment.