I would like to update a list of rows given by a list of IDs. Normally, the parameters of the query can be passed via the parameter property. But if I pass a list of IDs, Firebird will not accept the query. I'm using the FirebirdSql.Data.FirebirdClient from NuGet.
Code (simplified):
List<string> ids = someList.Select(_ => _.Id).ToList();
using (var fbCommand = new FbCommand("UPDATE someTable SET NAME='foo' WHERE ID IN (@ids)", fbConnection))
{
fbCommand.Parameters.Add("ids", ids);
fbCommand.ExecuteNonQuery();
}
The Table "someTable" is defined like this:
CREATE TABLE someTable (
ID CHAR(36),
NAME CHAR(20)
);
This is the exception:
Exception thrown: 'FirebirdSql.Data.FirebirdClient.FbException' in FirebirdSql.Data.FirebirdClient.dll An exception of type 'FirebirdSql.Data.FirebirdClient.FbException' occurred in >FirebirdSql.Data.FirebirdClient.dll but was not handled in user code arithmetic exception, numeric overflow, or string truncation string right truncation
where ID IN (@Param1, @Param2, @Param3, @Param4). You can have many params, indeed. But each param will be one scalar value. Equally in C+ you can haveint i1=1, i2=2, i3=3, i4=4;but it will be not one variable holding four numbers, it would be four variables holding one number each. Same with params. There is no text-to-text translation, there is not "string splicing" or "stirng interpolation" or what is the name. There really is a creation of variables and putting values into variables OUTSIDE of SQL query text. And that is intention!