Greetings Lazarus users,
I use Lazarus 1.2.4 to connect to MySQL 5.1. I am very new to Lazarus but I have a little bit of database programming before.
Suppose I have this table:
CREATE TABLE `mytable` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(20) NULL DEFAULT NULL,
`avalue` DECIMAL(10,2) NOT NULL DEFAULT '10000.00',
PRIMARY KEY (`id`)
)
ENGINE=MyISAM;
As you can see above, the field "avalue" have a default value of 10000.00.
Now, how to make TSQLQuery to fill that default value upon inserting record?
SQLQuery1.Close;
SQLQuery1.SQL.Text:='select * from mytable';
SQLQuery1.Open;
SQLQuery1.Append;
if SQLQuery1.FieldByName('avalue').AsFloat=10000 then
ShowMessage('Hooray I have a default value.')
else
ShowMessage('I do not have a default value. I think it is cool to have a default value here.');
SQLQuery1.Cancel;
Thank you.