Know the autoincremental ID before insert

Know the autoincremental ID before insert

Postby ben » Wed 02 Mar 2005 00:51

Hello, is it possible to know the auto incremental ID before doing the insert? Just to display in the user interface what is the next ID.

Thanks
ben
 
Posts: 119
Joined: Wed 17 Nov 2004 19:48

Postby Ikar » Wed 02 Mar 2005 09:03

Not, MySQL doesn't provide such functionality.
Ikar
 
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Postby ben » Wed 02 Mar 2005 23:39

Well, it supports:

show table status like 'tablename' and read the "Auto_increment" field.
ben
 
Posts: 119
Joined: Wed 17 Nov 2004 19:48

Postby Ikar » Thu 03 Mar 2005 12:34

In the interval between this query and Post execution it might be an insertion of records from another client
Ikar
 
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Postby ben » Thu 03 Mar 2005 19:25

yes thats why you are doing a LOCK TABLE before. Anyway my application is single user.
ben
 
Posts: 119
Joined: Wed 17 Nov 2004 19:48

Postby Ikar » Fri 04 Mar 2005 10:58

Your solution most likely will work.
Ikar
 
Posts: 1693
Joined: Thu 28 Oct 2004 13:56


Return to MySQL Data Access Components