perl scripts running under mod_perl environment ( with the help of
Apache::Registry) will be using new database handler ($dbh) at each
connection, unless you install Apache::DBI, which keeps the database
handle open throughout the Apache process.
Etienne Marcotte wrote:
EM: Date: Thu, 13 Dec 2001 13:30:32 -0500
EM: From: Etienne Marcotte <[EMAIL PROTECTED]>
EM: To: Carsten H. Pedersen <[EMAIL PROTECTED]>
EM: Cc: Henrik Erlandsson <[EMAIL PROTECTED]>,
EM: [EMAIL PROTECTED]
EM: Subject: [OT] mod_perl and last_insert_id() (Was: sequence and
EM: nextval)
EM:
EM: If running mod_perl does this stay true???
EM:
EM: Isn't mod_perl using an already opened connection to do subsequent
EM: manipulations?
EM:
EM: Or when one perl script is using a connection is creates a new
EM: connection for each perl script that starts running and if a perl script
EM: finishes, it keeps that same db handle for the next perl script asking a
EM: connection? If this is the case than I magine last_insert_id will always
EM: return the good value..
EM:
EM: sorry if this is mod_perl related
EM:
EM: Etienne
EM:
EM: "Carsten H. Pedersen" wrote:
EM: >
EM: > > Thanks, but how secure is this. Is it possible for two computers to do
EM: > > the "select" at the same time, i.e. get the new incremented value?
EM: > > Computer one insert, computer two insert, computer one select, computer
EM: > > two select?
EM: > >
EM: > > If this is possible how can I solve this? To make the column that insert
EM: > > the new nextval unique and then check for errors (non-unique insert) and
EM: > > if error then re-ask for a new nextval? Is this the best solution?
EM: > >
EM: >
EM: > It's not possible to mix up the values. The value returned
EM: > last_insert_id() is conncection specific, so each computer
EM: > will receive only the value that it generated.
EM: >
EM: > / Carsten
EM: > --
EM: > Carsten H. Pedersen
EM: > keeper and maintainer of the bitbybit.dk MySQL FAQ
EM: > http://www.bitbybit.dk/mysqlfaq
EM: >
EM: > > Thanks / Henrik
EM: > >
EM: > > ---
EM: > >
EM: > > create table MySequence ( nextval int(10) not null default '0'
EM: > > auto_increment ) ;
EM: > >
EM: > > insert into MySequence values ('');
EM: > > select LAST_INSERT_ID();
EM: > >
EM: > > is what I use....
EM: > >
EM: > > M
EM: > >
EM: > > -----Original Message-----
EM: > > From: Henrik Erlandsson [mailto:[EMAIL PROTECTED]]
EM: > > Sent: 13 December 2001 15:41
EM: > > To: [EMAIL PROTECTED]
EM: > > Subject: sequence and nextval
EM: > >
EM: > >
EM: > > Does the above functions exist in MySQL? If not, when do you think it's
EM: > > going to be implemented and how can I simulate nextval the easiest way?
EM: > >
EM: > > / Thanks Henrik
EM: >
EM: > ---------------------------------------------------------------------
EM: > Before posting, please check:
EM: > http://www.mysql.com/manual.php (the manual)
EM: > http://lists.mysql.com/ (the list archive)
EM: >
EM: > To request this thread, e-mail <[EMAIL PROTECTED]>
EM: > To unsubscribe, e-mail <[EMAIL PROTECTED]>
EM: > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
EM:
EM:
--
Sherzod Ruzmetov <[EMAIL PROTECTED]>
http://www.UltraCgis.com, Consultant
989.774.6265
+----------------------------------------+
| There is nothing wrong with your tools.|
| But we can make a better one. |
+----------------------------------------+
---------------------------------------------------------------------
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