the SELECT LAST_INSERT_ID() gets the last autoincremented number for the
current connection.

See  http://www.mysql.com/doc/G/e/Getting_unique_ID.html

The auto_incremenet field is sadly lacking in Oracle (IMHO).

M

-----Original Message-----
From: Henrik Erlandsson [mailto:[EMAIL PROTECTED]]
Sent: 13 December 2001 17:25
To: [EMAIL PROTECTED]
Subject: SV: sequence and nextval


Thanks, but how secure is this. Is it possible for two computers to do
the "select" at the same time, i.e. get the new incremented value?
Computer one insert, computer two insert, computer one select, computer
two select?

If this is possible how can I solve this? To make the column that insert
the new nextval unique and then check for errors (non-unique insert) and
if error then re-ask for a new nextval? Is this the best solution?

Thanks / Henrik

---

create table MySequence ( nextval  int(10) not null default '0'
auto_increment ) ;

insert into MySequence values ('');
select LAST_INSERT_ID();

is what I use....

M

-----Original Message-----
From: Henrik Erlandsson [mailto:[EMAIL PROTECTED]]
Sent: 13 December 2001 15:41
To: [EMAIL PROTECTED]
Subject: sequence and nextval


Does the above functions exist in MySQL? If not, when do you think it's
going to be implemented and how can I simulate nextval the easiest way?

/ Thanks Henrik


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to