Query parameters with Impala ODBC driver

…衆ロ難τιáo~ 提交于 2021-01-28 03:37:26

问题


I'm using the Impala ODBC driver provided by Cloudera. I can't seem to use query parameters correctly. For instance:

OdbcCommand command = DbConnection.CreateCommand();
command.CommandText = "INSERT INTO TABLE test VALUES(?, ?)";
command.Parameters.Add("key", OdbcType.VarChar).Value = "csharp";
command.Parameters.Add("val", OdbcType.VarChar).Value = "test";
command.ExecuteNonQuery();

throws the following exception.

{"ERROR [HY000] [Cloudera][ImpalaODBC] (110) Error while executing a query in Impala: [HY000] : AnalysisException: Syntax error in line 1:\nINSERT INTO TABLE test VALUES(?, ?)\n
^\nEncountered: Unexpected character\nExpected: CASE, CAST, EXISTS, FALSE, IF, INTERVAL, NOT, NULL, TRUNCATE, TRUE, IDENTIFIER\n\nCAUSED BY: Exception: Syntax error\n"}

Which should manage query parameters (and replacement of ? by values), ODBC library or the driver ? It seems to be the driver and in this case, it's not implemented... And it's a shame because I cannot use prepared statement.

Does somebody know a way to use query parameters with the Impala ODBC driver?


回答1:


INSERT INTO TABLE is Impala specific syntax. To use Impala ODBC to do INSERT with parameters you need the SQL 92 syntax which is INSERT INTO <table name> ...

Can you try the following syntax and see if it help?

INSERT INTO test VALUES(?, ?)



来源:https://stackoverflow.com/questions/34093083/query-parameters-with-impala-odbc-driver

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!