[UNBOUND_SQL_PARAMETER] When running Placeholder query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 01:07 PM
I am using the databricks-sql-go library version 1.5.2. I am trying to run a query with placeholders of type '?'
The query looks like
sql := fmt.Sprintf(`SELECT COUNT(*) FROM %s.%s WHERE %s IN (%s)`, schema, table, column, strings.Join(params, ", "))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 07:40 PM - edited 02-07-2024 07:41 PM
# Query parameters
Passing parameters to a query is supported when run against servers with version DBR 14.1.
p := dbsql.Parameter{Name: "p_bool", Value: true},
rows, err1 := db.QueryContext(ctx, `select * from sometable where condition=:p_bool`,dbsql.Parameter{Name: "p_bool", Value: true})databricks-sql-go/doc.go at main · databricks/databricks-sql-go (github.com)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 12:38 AM
This works fine when I have to pass just 1 argument. But how will this work where I have n number of values to pass inside an IN clause?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 01:58 PM
Can you print out an example after the Sprintf substitutions?
It seems you generated a query with a named parameter: ":_58" But args (which should be a Map) does not have a key named "_58".