 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
kenshiro2000 Guest
|
Posted: Fri Dec 12, 2003 11:19 am Post subject: Index AutoIncrement in MYSQL |
|
|
Hi, i'm working with BCB6 on a MYSQL DB. I've defined some tables with primary key of autoincrement type.
Now if i insert a new record, i don't know what is the index that the DB create for me. How can i retrive this index?
I need this beacuse if i have a primary key relationed with a foreign key present in another table, when i insert a new record on the first table i must create a related record on the second table and i must insert the same index.
Is there a SQL command permitting to retrive last index created?
My Application is a client/server application, then the last inserted index is relative to every client, i hope....
tnx
Ken
|
|
| Back to top |
|
 |
Jayme Jeffman Filho Guest
|
Posted: Fri Dec 12, 2003 4:25 pm Post subject: Re: Index AutoIncrement in MYSQL |
|
|
Hello,
From the MySQL manual :
"LAST_INSERT_ID([expr])
Returns the last automatically generated value that was inserted into an AUTO_
INCREMENT column."
You can pass this expression as a query to the MySQL database.
HTH
Jayme.
"kenshiro2000" <kenshiro2000 (AT) libero (DOT) it> wrote
| Quote: |
Hi, i'm working with BCB6 on a MYSQL DB. I've defined some tables with primary key of autoincrement type.
Now if i insert a new record, i don't know what is the index that the DB create for me. How can i retrive this index?
I need this beacuse if i have a primary key relationed with a foreign key present in another table, when i insert a new record on the first table i must create a related record on the second table and i must insert the same index.
Is there a SQL command permitting to retrive last index created?
My Application is a client/server application, then the last inserted index is relative to every client, i hope....
tnx
Ken
|
|
|
| Back to top |
|
 |
Scott Metzger Guest
|
Posted: Fri Dec 12, 2003 4:45 pm Post subject: Re: Index AutoIncrement in MYSQL |
|
|
Assuming your MySQL component is derived from TDataSet or shares the
same functionality you can use InsertRecord to insert a new record.
When you use InsertRecord "The newly inserted record becomes the active
record." You can then read your index value from the active record.
Scott Metzger
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|