Closed jp200k closed 2 weeks ago
@jp200k Can you format the code as a code snippet? It's hard to read now.
According to duckdb doc prepared_statements, no start with @
paramter accept. Can you try to use like $city
? @jp200k
This is a common scenario people run into (including myself). As @Cricle stated, the parameters need to be prefixed with $
not @
. Otherwise you get the referenced error, which is a little misleading.
@jp200k so instead of:
INSERT INTO weather (city, temp_lo, temp_hi, prcp, date, id)
VALUES (@city, @temp_lo, @temp_hi, @prcp, @Date, @id);
try:
INSERT INTO weather (city, temp_lo, temp_hi, prcp, date, id)
VALUES ($city, $temp_lo, $temp_hi, $prcp, $Date, $id);
@brendonparker Thanks for confirming that this is not a DuckDB.NET issues. This is documented in the docs: https://duckdb.net/docs/basic-usage.html#parameterized-statements
When using DuckDB 1.0 in C#, I got the following error: Binder Error: Referenced column "city" not found in FROM clause! LINE 1: ..._lo, temp_hi, prcp, date, id) VALUES (@city, @temp_lo, @temp_hi, @prcp, @date,...
my statement is: INSERT INTO weather (city, temp_lo, temp_hi, prcp, date, id) VALUES (@city, @temp_lo, @temp_hi, @prcp, @date, @id ); where the DuckDBParameter are all correctly assigned, including ParameterName, SourceColumn, DateType and Value.
If NOT using parameters and hard coding above insert statement, it works well. When using parameters, I got above error. Searching the web, I found other users got similar error message but their causes might be different. However, here the "FROM clause" is not relative.
Thank you for your hard work.