Yes you are correct.
Use widestring in parameter. If array size is big it will give you error
OK, you'll have to explain that.
Are you trying to pass WideStrings as a Parameter for the IN-Clause?
You do know, that SQLite uses UTF8 per Default?
What exactly are you trying to do?
EDIT: I have to amend my Sample above.
It wouldn't work, since the Parameter would be replaced with something like
.... WHERE emp IN ('13, 42')
which would return probably nothing.
Frankly, i dislike the IN-Operator with multiple values.
In that case i'd rather use a CTE, but that one doesn't allow Parameters.
Depends if the User can enter Values, or just choose from a list
should go more like this:
ses SysUtils;
Var
Q:TSQLQuery;
a:Array Of String;
Begin
SetLength(a, 3);
a[0]:='13''';
a[1]:='''42''';
a[2]:='''97';
Q.SQL.Text:='Select * from emp where emp in (?)'; //You really have a FieldName which is the SAME as the TableName?!?!?!?
Q.Params[0].AsString:=String.Join(', ', a);
Q.Open;
EDIT2: Wouldn't work either, since it doubles the singlequotes to escape them
Ah, well. Would be probably go with a staging-table, if i really need to use Parameters
EDIT3: Found this:
https://forum.lazarus.freepascal.org/index.php?topic=31182.0Bottom line: It doesn't work with Parameters. Only with injection into the SQL-Text, and then a String-Array is enough
Parameters are for single-Values
the IN-Operator only makes sense if you want to compare against multiple Values, since it's a shortcut for
".... WHERE SomeCol=Value1 OR SomeCol=Value2 OR SomeCol=Value3..." etc.
All that said: I'd probably go for a combined solution of a staging-table with a CTE using an Inner Join