Retrieving the AutoInc Id from Insert (Borland Builder 6)
Posted: Tue 15 Aug 2006 13:34
Hi,
I would like to request some assistance with learning the id which was auto-inc generated by the table when new descriptions are inserted.
For Example, the table:
The creation of a new record:
Once this is performed how can I find out what number was given to 'red'?
I can't just look up the last record as another user may have added a new colour simultaneously.
Many thanks in advance.
I would like to request some assistance with learning the id which was auto-inc generated by the table when new descriptions are inserted.
For Example, the table:
Code: Select all
CREATE TABLE `myDatabase`.`myTable` (
`id` INTEGER UNSIGNED AUTO_INCREMENT,
`description` VARCHAR(45) NOT NULL DEFAULT '',
PRIMARY KEY(`id`)
)
ENGINE = InnoDB;
Code: Select all
if(!MyConnection1->InTransaction)
{
MyQuery1->SQL->Text = "insert into myDatabase.mytable (description) values ('red');";
MyQuery1->Execute();
}
I can't just look up the last record as another user may have added a new colour simultaneously.
Many thanks in advance.