CREATE TABLE Customers (
Id smallint(5) unsigned NOT NULL AUTO_INCREMENT,
Name char(40) DEFAULT NULL,
Comision float(12,2) DEFAULT NULL,
PRIMARY KEY (Id)
) ENGINE=MyISAM AUTO_INCREMENT=91 DEFAULT CHARSET=latin1
MyQuery1.SQL.Text := 'select * from Customers where id in (:num);';
MyQuery1.ParamByName('num').AsString := '125,188,225,216';
MyQuery1.Execute;
Error in result
MyQuery1.SQL.Text := 'select * from Customers where id in (&num);';
MyQuery1.MacroByName('num').AsString := '125,188,225,216';
MyQuery1.Execute;
Error in result
As is it done?
Using macro or param
-
swierzbicki
- Posts: 451
- Joined: Wed 19 Jan 2005 09:59
That is designed as is. You can't pass a string as "list". When you are using .AsString, you are just sending a String. Delphi will replace it :
MyQuery1.SQL.Text := 'select * from Customers where id in (:num);';
MyQuery1.ParamByName('num').AsString := '125,188,225,216';
will be executed like this :
select * from Customers where id in ('125,188,225,216')
instead of
select * from Customers where id in (125,188,225,216)
Try to use macros:
MyQuery1.SQL.Text := 'select * from Customers where id in (&num);';
MyQuery1.MacroByName('num').Vaule := '125,188,225,216';
MyQuery1.SQL.Text := 'select * from Customers where id in (:num);';
MyQuery1.ParamByName('num').AsString := '125,188,225,216';
will be executed like this :
select * from Customers where id in ('125,188,225,216')
instead of
select * from Customers where id in (125,188,225,216)
Try to use macros:
MyQuery1.SQL.Text := 'select * from Customers where id in (&num);';
MyQuery1.MacroByName('num').Vaule := '125,188,225,216';