Closed bnuzhouwei closed 9 months ago
@bnuzhouwei DuckDB itself doesn't support named parameters
Could implement the parameters in the driver just like SQLite
SQLite has sqlite3_bind_parameter_index
api that returns index of the parameter given it's name. There is no such API in DuckDB.
The same issue exists in ClickHouse driver of ADO, while the jdbc driver works well among different databases. It's a pitty for .NET Ecosystem that hard to get consistent api of ADO among different databases.
You can open an issue for named parameters at the DuckDB repository If it gets added, I'll add support for it too.
I have submit the issue: Named parameters support
You can use DynamicParameters Bag, which is basically a Dictictionary<string, object> like follows:
connectionn.Execute("INSERT INTO TestTable (Id,Name) VALUES ($1,$2)", new Dictionary<string, object> { { "$1", 1 }, { "$2", "some string" } });
Sounds that named parameters are now supported by DuckDB: https://github.com/duckdb/duckdb/pull/5611
The necessary Api for named parameters isn't exposed in the C Api.
@Seddryck There is now a PR for this in DuckDB, once it gets merged and released it can be added to the library as well: Add support for named parameters in prepared statements
With the release of DuckDB 0.9.0, this is finally available (currently in the develop branch)
ADO default use @param as paremnt, but duckdb use ?, can fill the gap with specified name of parameters?