IN() query statement not possible with parameters
See original GitHub issueThe following query throws an error:
con.query(`SELECT * FROM BDDIVE#DAT.BDKSTP WHERE kstp.KSKST IN (?)`, [[4434, 4438]])
It throws the error [odbc] Error binding parameters
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Parameterize an SQL IN clause - Stack Overflow
You can parameterize each value, so something like: string[] tags = new string[] { "ruby", "rails", "scruffy", "rubyonrails" }; string cmdText = "SELECT...
Read more >Using Parameters for SQL Server Queries and Stored ...
In this tip we look at different ways to parameterize a SQL Server query.
Read more >Execute SQL Task - SQL Server Integration Services (SSIS)
Use the Parameter Mapping page of the Execute SQL Task Editor dialog box to map variables to parameters in the SQL statement. Options....
Read more >Passing parameters to SQL queries - Psycopg
Passing parameters to a SQL statement happens in functions such as Cursor.execute() by using %s placeholders in the SQL statement, and passing a...
Read more >Working with parameters in the sp_executesql stored procedure
This article will show how to use the sp_executesql system stored procedure to run static and dynamic SQL queries.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Would like to upvote this. Queries like
works in libraries like
mysql
/mysql2
,mssql
etc. The workaround suggested, joining the values to a string does at least not seem to work with a Databricks database.Using multiple question marks (
IN (?, ?...)
) works, but is not very clean when you have a dynamic number of values - you’d have to generate the number of questions marks n times, so the query is no longer a constant string.It took a bot to spur me into action. Whomever owns this query() function could map the values to the appropriate number of question marks in the IN list. Further, OPEN USING SUBSET could be used to such that there’s always 1000 or whatever entries in the IN list, but on each usage, the actual number of IN list entries are identified. That would bridge functional behavior and performance.