Issue with AsBoolean casting & UNION
Posted: Mon 14 Mar 2011 19:17
Delphi XE & MyDAC 6
With UNION statement, AsBoolean causing exeception.
Code: Select all
CREATE TABLE `tab` (
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`a` BOOLEAN NOT NULL,
PRIMARY KEY (`id`)
)
ENGINE = InnoDB;
insert into tab(a) values('1');
insert into tab(a) values('1');
insert into tab(a) values('0');
insert into tab(a) values('1');
insert into tab(a) values('0');
insert into tab(a) values('0');
insert into tab(a) values('0');Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
var
B: Boolean;
begin
myquery1.SQL.Text := 'select a from tab WHERE a=0 UNION select a from tab WHERE a=1';
myquery1.Open;
while not myquery1.Eof do
begin
B := myquery1.Fields[0].AsBoolean;
myquery1.Next;
end;
myquery1.Close;
end;