Reputation:
My following Delphi code is throwing a compiler error: incompatible type: string and integer in line
SQL.Text := 'Select ColumnA from TableA where ColumnA NOT IN ('+ 3 + ',' + 4 +')';
How do I put the numbers in the SQL statement?
Upvotes: 2
Views: 298
Reputation: 11860
When writing these sort of statements (and parameters are not in scope), try to use the Format function:
SQL.Text := Format('Select ColumnA from TableA where ColumnA NOT IN (%d,%d)',
[Firstval, SecondVal]);
One big advantage writing the query this way is that you keep the SQL statement readable (like when you use parameters).
Upvotes: 7
Reputation: 4776
This line should look like this:
SQL.Text := 'Select ColumnA from TableA where ColumnA NOT IN (3,4)';
Upvotes: 1