Dear friends,
1. https://bugs.mysql.com/bug.php?id=78934
2.
https://dev.mysql.com/doc/refman/5.7/en/information-functions.html#function_last-insert-id
The document (2) says that LAST_INSERT_ID() will not be changed if no rows
are inserted successfully. But (1) says that it's undefined wh
Gary Smith wrote:
Steve Edberg wrote:
(2) autoincrement values are not reused after deletion, so if you
deleted the record with ID=1000 inserted in (1), the next
autoincrement would still be 1001, even if the existing records are
IDs 1,2,3. This is usually the desired behavior, but again, may
Gary Smith skrev:
...
An example of where it wouldn't be: Although ID is auto_increment, you
could define a row as, say, '10005583429'. This would be a valid input.
Selecting max(id) would return that number. However, auto_increment
wouldn't change - it would still be '34' (or whatever) for t
Steve Edberg wrote:
(2) autoincrement values are not reused after deletion, so if you
deleted the record with ID=1000 inserted in (1), the next
autoincrement would still be 1001, even if the existing records are
IDs 1,2,3. This is usually the desired behavior, but again, may not be
what *you*
On Sun, Dec 27, 2009 at 1:30 PM, Gary Smith wrote:
> Victor Subervi wrote:
>
>> On Sun, Dec 27, 2009 at 12:00 PM, Michael Dykman
>> wrote:
>>
>>
>>
>>> last_insert_id() returns the last id auto-incremented in *the current
>>> session*. If
all
| |
++--+--+---++-+---++--++-+--+---+--+---+---++--+--+--+--+-+--+
1 row in set (0.00 sec)
mysql> select last_insert_id() from products;
+--+
| last_insert_id() |
+--+
|0 |
+--+
1 row in set (0.00 sec)
mysql>
Now, I was expecting 1, not 0! Wha
Victor Subervi wrote:
On Sun, Dec 27, 2009 at 12:00 PM, Michael Dykman wrote:
last_insert_id() returns the last id auto-incremented in *the current
session*. If you disconnect and reconnect, it can not be retrieved.
Ahah! So how do I retrieve the last id inserted irrespective of
On Sun, Dec 27, 2009 at 12:00 PM, Michael Dykman wrote:
> last_insert_id() returns the last id auto-incremented in *the current
> session*. If you disconnect and reconnect, it can not be retrieved.
>
Ahah! So how do I retrieve the last id inserted irrespective of connection?
TIA,
V
last_insert_id() returns the last id auto-incremented in *the current
session*. If you disconnect and reconnect, it can not be retrieved.
- michael dykman
On Sun, Dec 27, 2009 at 11:42 AM, Victor Subervi
wrote:
> On Sun, Dec 27, 2009 at 11:27 AM, Mattia Merzi wrote:
>
>> 2009/
On Sun, Dec 27, 2009 at 11:27 AM, Mattia Merzi wrote:
> 2009/12/27 Victor Subervi :
> > mysql> select * from products;
> [...]
> > mysql> select last_insert_id() from products;
> [...]
> > Now, I was expecting 1, not 0! What up?
>
> [...] LAST_INSER
2009/12/27 Victor Subervi :
> mysql> select * from products;
[...]
> mysql> select last_insert_id() from products;
[...]
> Now, I was expecting 1, not 0! What up?
[...] LAST_INSERT_ID() (no arguments) returns the first
automatically generated value successfully inserted for
an
+
1 row in set (0.00 sec)
mysql> select last_insert_id() from products;
+--+
| last_insert_id() |
+--+
|0 |
+--+
1 row in set (0.00 sec)
mysql>
Now, I was expecting 1, not 0! What up?
TIA,
Victor
Thank you very much for all answers
I will trying Triggers and the example with the update after an INSERT.
Ant then, I use the best for me;-)
Thunder
Yes, Triggers... I so rarely use them I forget they exist.
On Tue, May 5, 2009 at 10:22 AM, Thomas Pundt wrote:
Johnny Withers schr
Yes, Triggers... I so rarely use them I forget they exist.
On Tue, May 5, 2009 at 10:22 AM, Thomas Pundt wrote:
> Johnny Withers schrieb:
>
>> Well, I think an update after insert is the only way. Other than
>> perpopulating another table with possibe crc values then usinga join:
>>
>> Select id
Johnny Withers schrieb:
Well, I think an update after insert is the only way. Other than
perpopulating another table with possibe crc values then usinga join:
Select id from testtable
Inner join crctable on testtable.id=crctable.id
Where crctable.crcval='xxx'
Just be sure to index the crcva
can make an Update, the Value is 0...
>
>
>
> I don't think its possible to do what you want in a single statement. Since
> LAST_INSERT_ID() is set to the last insert id of the connection... and the
> row you are inserting doesn't exist.. well.. until you create it, it will
I'm so sorry for the mistake...
I mean:
I think it is to slow when I make a SELECT later in this form:
I don't think its possible to do what you want in a single statement. Since
LAST_INSERT_ID() is set to the last insert id of the connection... and the
row you are inserting doe
WHERE CRC32(id) = "46316330"
0.5712 sec.
OK, I can make an UPDATE after an INSERT but then I can't use UNIQUE for
the Coloumn with the CRC32...
Before I can make an Update, the Value is 0...
I don't think its possible to do what you want in a single statement. Since
LAST_INSERT_I
I don't think its possible to do what you want in a single statement. Since
LAST_INSERT_ID() is set to the last insert id of the connection... and the
row you are inserting doesn't exist.. well.. until you create it, it will
always either be zero or the record BEFORE your next insert, i
gt; CRC32('2')
3 1842515611 --> CRC32('3')
I would like insert the CRC32 directly when I make a new Insert. E.G.
INSERT INTO `db283796092`.`testtable`
(
`id` , `id-crc`
)
VALUES (
NULL , LAST_INSERT_ID()
);
But LAST_INSERT_ID() is 0 How can I make that, that he use the ac
installs. For example another 64
> bit machine has a MySQL rpm rev of 5.0.27
>
> I have a valid DB handle and after an insert I try to get the ID of
> that inserted row, a la:
>
> my $id = $DBH->last_insert_id();
>
>
> This has been working everywhere until I
Do you have the latest version of DBI and DBD::mysql installed?
First try:
$ cpan
cpan> install DBI
cpan> install DBD::mysql
You can also do:
my $sth = $dbh->prepare("select last_insert_id()");
$sth->execute();
my ($last_insert_id) = $sth->fetchrow_array();
Octavia
t the ID of
that inserted row, a la:
my $id = $DBH->last_insert_id();
This has been working everywhere until I tried installing the exact
same script on this newest machine. When the script runs now I get:
DBI last_insert_id: invalid number of arguments: got handle + 0, expect
garments_to_sizes and
garments_to_categories look up tables. Do I need to do this manually or can
I use the last_insert_id() function? But not sure if this would work since
I¹m not populating the garments table one row at a time I¹m inserting all
info in one go with LOAD DATA INFILE, as mentioned
ve to try
to enter the correct garment_id from the garments table into the correct
foreign key fields in the garments_to_colour, garments_to_sizes and
garments_to_categories look up tables. Do I need to do this manually or can
I use the last_insert_id() function? But not sure if this would work since
I
LECT * FROM table WHERE column=Whatever
I found LAST_INSERT_ID but i doesn't work
What I want to do is:
1-user has 10 columns (fields).
2- User updated one of these fields using CONCAT_WS(adding new data to previous
data).
3- When user views any of his information he sees only the last
Mike Kruckenberg wrote:
mysql> SET @staff_id = LAST_INSERT_ID();
Query OK, 0 rows affected (0.01 sec)
I don't know if this behaviour has changed in later versions of mysql,
but using session variables, although lovely, was the quickest way to
break replication (at least up to and i
ROLLBACK.
>> This is acceptable in my case.
>>
>> What I really want to avoid is what I am doing now: open one transaction to
>> insert, or update, or delete certain information and close with the commit.
>> Then, I get the LAST_INSERT_ID() and open another transacti
mmit.
Then, I get the LAST_INSERT_ID() and open another transaction to write my
audit trail. However, if the first one went through ok but if I got a
problem at the second transaction, I need to delete the inserted or updated
or move back the deleted information. This doesn't work well.
I get the LAST_INSERT_ID() and open another transaction to write my
audit trail. However, if the first one went through ok but if I got a
problem at the second transaction, I need to delete the inserted or updated
or move back the deleted information. This doesn't work well.
Let's expand my
Andre Matos wrote:
SET AUTOCOMMIT=0;
START TRANSACTION;
INSERT INTO staff (`Name`) VALUES ('ABC');
INSERT INTO changes (`Key`, `Table`, `Value`) VALUES (LAST_INSERT_ID(),
'staff', 'ABC');
COMMIT;
SET AUTOCOMMIT=1;
This works fine in my test environment, however
('ABC');
INSERT INTO changes (`Key`, `Table`, `Value`) VALUES (LAST_INSERT_ID(),
'staff', 'ABC');
COMMIT;
SET AUTOCOMMIT=1;
This works fine in my test environment, however what about many users doing
at the same time. Does the LAST_INSERT_ID() get the correct ID for each
u
changes" table.
SET AUTOCOMMIT=0;
START TRANSACTION;
INSERT INTO staff (`Name`) VALUES ('ABC');
INSERT INTO changes (`Key`, `Table`, `Value`) VALUES (LAST_INSERT_ID(),
'staff', 'ABC');
COMMIT;
SET AUTOCOMMIT=1;
This works fine in my test environment, however what
Afshad Dinshaw wrote:
Hi
Im using the latest version of mysql.
When I run the following query :
select last_insert_id()
if get the error message:
function vcontacts.last_insert_id does not exist
note: vcontacts is the name of my database.
anyone know why?
thanks
I can run it both
Hi
Im using the latest version of mysql.
When I run the following query :
select last_insert_id()
if get the error message:
function vcontacts.last_insert_id does not exist
note: vcontacts is the name of my database.
anyone know why?
thanks
On Jun 30, 2006, at 10:44 AM, Rob Desbois wrote:
That leaves me with ON DUPLICATE KEY UPDATE. It's not amazingly
helpful as you have to provide a column to update - however I can
just say e.g.
ON DUPLICATE KEY UPDATE id=id
The problem with this is that if I then do "SELECT LAST
me with ON DUPLICATE KEY UPDATE. It's not amazingly helpful as you
have to provide a column to update - however I can just say e.g.
ON DUPLICATE KEY UPDATE id=id
The problem with this is that if I then do "SELECT LAST_INSERT_ID();" then I
don't get the id of the 'upda
d.
I am having trouble getting the same functionality with MySQL.
INSERT INTO TABLE (...)
SELECT LAST_INSERT_ID() as adid
I get this MySQL error:
You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near 'INSERT
IN
> it might be best to ask this in the cf forums, however did
> you try to separate the statements with a ; ? I haven't tried
> 2 query statements for MySQL in cfquery...yet ;-) Also I
> believe MySQL 3.23+ supports @@identity
Yes I've tried semicolons after the statements, and I've tried setting
a
ET NOCOUNT OFF
>
>
> That whole block was processed in coldfusion as a single query. I gave
> it a name of "insertquery", and I can get the ID back as
> insertquery.adid.
>
> I am having trouble getting the same functionality with MySQL.
>
> INSERT INTO
of "insertquery", and I can get the ID back as
insertquery.adid.
I am having trouble getting the same functionality with MySQL.
INSERT INTO TABLE (...)
SELECT LAST_INSERT_ID() as adid
I get this MySQL error:
You have an error in your SQL syntax; check the manual that corresponds
to
t the beginning of each script.
This seems fine to me as I don't want to lock the tables, and the
last_insert_id is performed in the same file than the insert, so on the per
connection basis it's perfect (thank you very much for your help!!).
But it seems a bit strange to me to open so many
ply-To: "'mysql@lists.mysql.com '"
To: mel list_php <[EMAIL PROTECTED]>
CC: mysql@lists.mysql.com
Subject: Re: last_insert_id
Date: Tue, 15 Feb 2005 10:50:40 +
mel list_php wrote:
Hi!
I have a database where several users can connect and input data.
I managed to have my
'"
To: mel list_php <[EMAIL PROTECTED]>
CC: mysql@lists.mysql.com
Subject: Re: last_insert_id
Date: Tue, 15 Feb 2005 10:50:40 +
mel list_php wrote:
Hi!
I have a database where several users can connect and input data.
I managed to have my insert queries as atomic, but I was wonderin
.
- if one user inserts and retrieves the id, but between both one other
has inserted something the id returned will be the right one?
Last_insert_id() is consistent on a per-connection basis, meaning you
don't need to use lock (hopefullly !)
http://dev.mysql.com/doc/mysql/en/getting-u
, execute the query, retrieve the id,
unlock
> the table?
>
> - is there a way to make an atomic query with this that would avoid me
to
> use locks?
last_insert_id is on a per-connection basis i.e. it gives the last id
inserted using that particular connection. Therefore you will alway
Hi,
You can probably use "SELECT LAST_INSERT_ID()" which keeps
auto-increment values on a per connection basis.
See:
http://dev.mysql.com/doc/mysql/en/getting-unique-id.html
/Johan
mel list_php wrote:
Hi!
I have a database where several users can connect and input data.
I managed to have
Hi!
I have a database where several users can connect and input data.
I managed to have my insert queries as atomic, but I was wondering about one
special case: I make one insert, and retrieve the last id inserted by mysql
because I need to update an other table with that id.
- if one user inser
L PROTECTED]>
Subject: Re: Rollback and INSERT_ID() or LAST_INSERT_ID()
Date: Tue, 18 Jan 2005 11:08:40 +0100
Hi!
Am Di, den 18.01.2005 schrieb Paul DuBois um 3:53:
> At 21:27 -0500 1/17/05, Andre Matos wrote:
> >Thanks Eric, but I can let it increment because I cannot have a gave in
the
>
Hi!
Am Di, den 18.01.2005 schrieb Paul DuBois um 3:53:
> At 21:27 -0500 1/17/05, Andre Matos wrote:
> >Thanks Eric, but I can let it increment because I cannot have a gave in the
> >numbers. I think I will need to use MAX() in this case.
>
> Using MAX() won't guarantee that you won't have gaps.
>
Yes, I know about this. What I plan is to remove the auto_increment. I will
do this by hand locking the entire table just right before inserting the
field. Actually, it is running like this. I am just upgrading the PHP.
I will keep the auto_increment in other tables that does not have this kind
of
At 21:27 -0500 1/17/05, Andre Matos wrote:
Thanks Eric, but I can let it increment because I cannot have a gave in the
numbers. I think I will need to use MAX() in this case.
Using MAX() won't guarantee that you won't have gaps.
What you're describing cannot be achieved in the general case.
Conside
Thanks Eric, but I can let it increment because I cannot have a gave in the
numbers. I think I will need to use MAX() in this case.
Thanks.
Andre
On 1/17/05 8:14 PM, "Eric Bergen" <[EMAIL PROTECTED]> wrote:
> Just let it increment. Keeping it incremented is MySQL's way ot
> insuring that the
Just let it increment. Keeping it incremented is MySQL's way ot
insuring that the same id doesn't get used twice for different
records. It's doing everything correctly.
-Eric
On Mon, 17 Jan 2005 19:06:45 -0500, Andre Matos
<[EMAIL PROTECTED]> wrote:
> Hi List,
>
> I have a field in one of my tab
Hi List,
I have a field in one of my tables that uses auto-increment from MySQL
4.1.8-nt (Windows XP).
My problem is to get the last insert ID when the insert fails and I use
rollback. The MySQL is still incrementing the field. How can I avoid this if
it is possible? I am trying to avoid to use t
Hello.
As said at:
http://dev.mysql.com/doc/mysql/en/Information_functions.html
"If you insert many rows at the same time with an insert statement,
LAST_INSERT_ID() returns the value for the first inserted row."
LOAD DATA INFILE inserts several rows a time, so this
Hi,
I am trying to find in the manual what select last_insert_id() will return
after a load data infile command is executed.
>From my experiments, it returns the id of the FIRST record in the file, I
would have expected the LAST, but that is not the case.
Is that documented somewhere? Ca
; I'm writing an app in Perl / Gtk2, and I'm having trouble with DBI's
>> last_insert_id() function.
>> I have so far:
>>
>> > eval {
>> > $sth->execute (@bind_values) || die $dbh->errstr;
>> >
m having trouble with DBI's
> last_insert_id() function.
> I have so far:
>
> > eval {
> > $sth->execute (@bind_values) || die $dbh->errstr;
> > };
> >
> > # If the above failed, there will be something in the special
> &g
Paul McNeil wrote:
last_insert_id() should work. You are updating using @bind_values. What is
the text of that? Does it indeed create a record?
@bind_values is an array of values that gets populated from my form.
It has the same number of elements as the number of placeholders in my
SQL
last_insert_id() should work. You are updating using @bind_values. What is
the text of that? Does it indeed create a record?
God Bless
Paul C. McNeil
Developer in Java, MS-SQL, MySQL, and web technologies.
GOD BLESS AMERICA!
To God Be The Glory!
-Original Message
You wrote
> $pk = $dbh->last_insert_id();
I believe you can get the created ID with the query, "Select @@IDENTITY;"
This returns the last created ID from the connector object.
Peace
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysq
Hi all.
I'm writing an app in Perl / Gtk2, and I'm having trouble with DBI's
last_insert_id() function.
I have so far:
eval {
$sth->execute (@bind_values) || die $dbh->errstr;
};
# If the above failed, there will be something in the specia
"paqogomez" <[EMAIL PROTECTED]> wrote:
> I am trying to build a stored procedure in v. 5.
> This is what I have so far.
>
> delimiter |
> create procedure get_id(out oid int)
> begin
>insert into mercury.merchant (name) values(null);
>select last
I am trying to build a stored procedure in v. 5.
This is what I have so far.
delimiter |
create procedure get_id(out oid int)
begin
insert into mercury.merchant (name) values(null);
select last_insert_id() into @mid;
insert into mercury.customers( address1 ) values (null);
select
hanks,
Matt
> -Original Message-
> From: Matt Chatterley [mailto:[EMAIL PROTECTED]
> Sent: 23 April 2004 02:08
> To: 'MySQL List'
> Subject: LAST_INSERT_ID() and Stored Procs
>
> Hi all.
>
> Another hiccup along the happy road with MySQL 5.0!
>
>
Hi all.
Another hiccup along the happy road with MySQL 5.0!
The last bit of a stored procedure I have just put together does this:
-- insert cluster row
INSERT INTO clusters (Name) VALUES (sName);
SELECT LAST_INSERT_ID() INTO iNewClusterID;
-- insert map row
INSERT INTO map (X, Y) VALUES (iX
Thanks, Mark, for the syntax. I had actually played around enough to
figure it out already and got it to work the way that I wanted to. I
guess when I asked the question, I wasn't fully aware of what I was
wanting. The LAST_INSERT_ID wasn't a major issue. I ended up using the
foll
Hi Jason,
For MyISAM tables only, you can manually set the auto
increment counter using the syntax:
ALTER TABLE table_name AUTO_INCREMENT = 1000
Keep in mind, however, that this does not change the
value of the LAST_INSERT_ID() since it still
represents the value last inserted. On a freshly
I have a ticketing system that sets the ID of the ticket as the
LAST_INSERT_ID. By default, it was counting up from 0. I updated the
ID of the last ticket to reflect a different numbering scheme
(MM). I would like to automate this but I don't want to change
the ID of a current t
Don't forget that if you "commit" then last_insert_id will return 0
- Original Message -
From: "William R. Mussatto" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 24, 2003 6:56 PM
Subject: Re: last_insert_id()
: R.Dobson sa
R.Dobson said:
> Hi,
>
> Is it possible to obtain the last_insert_id() for a particular column in
> a particular table?
> eg, say i wanted to obtain the last insert id of a column called id in
> table reference, something along the lines of:
>
> last_insert_id(reference.
Hi,
Is it possible to obtain the last_insert_id() for a particular column in
a particular table?
eg, say i wanted to obtain the last insert id of a column called id in
table reference, something along the lines of:
last_insert_id(reference.id)
The reason I ask is because I want to initially
At 16:02 +0300 6/17/03, Baris Akin wrote:
Hello,
I try to get last inserted autoincrement record ID on table with
LAST_INSERT_ID() function (SELECT LAST_INSERT_ID() FROM TABLE). Every
connection returns it's own last inserted ID not actual ID. Is this a
bug? Also it returns more tha
"Baris Akin" <[EMAIL PROTECTED]> wrote:
> LAST_INSERT_ID() function (SELECT LAST_INSERT_ID() FROM TABLE). Every
> connection returns it's own last inserted ID not actual ID. Is this a
> bug?
No. LAST_INSERT_ID() works per-connection. It returns the last inserted auto
On Tue, Jun 17, 2003 at 04:02:46PM +0300, Baris Akin wrote:
> I try to get last inserted autoincrement record ID on table with
> LAST_INSERT_ID() function (SELECT LAST_INSERT_ID() FROM TABLE). Every
> connection returns it's own last inserted ID not actual ID. Is this a
> bug?
Hello,
I try to get last inserted autoincrement record ID on table with
LAST_INSERT_ID() function (SELECT LAST_INSERT_ID() FROM TABLE). Every
connection returns it's own last inserted ID not actual ID. Is this a
bug? Also it returns more than one record (20 rows).
Thanks
Baris
On Wednesday 26 March 2003 08:25, you wrote:
> > A programmer just asked me about a possible race condition,
> > and I didn't know what to answer:
> >
> > If I insert a line using autoincrement, then ask for last_insert_id()
> > am I guaranteed to get the same I
> A programmer just asked me about a possible race condition,
> and I didn't know what to answer:
> If I insert a line using autoincrement, then ask for last_insert_id()
> am I guaranteed to get the same ID I just inserted?
Yes
> It seems that another program could be ins
Hi,
On Wed, Mar 26, 2003 at 03:17:42PM +0100, Steve Rapaport wrote:
> A programmer just asked me about a possible race condition,
> and I didn't know what to answer:
>
> If I insert a line using autoincrement, then ask for last_insert_id()
> am I guaranteed to get the sam
A programmer just asked me about a possible race condition,
and I didn't know what to answer:
If I insert a line using autoincrement, then ask for last_insert_id()
am I guaranteed to get the same ID I just inserted?
It seems that another program could be inserting at almost the same
time
CREATE TABLE test (
> -> a INT UNSIGNED AUTO_INCREMENT NOT NULL ,
> -> b INT UNSIGNED NOT NULL,
> -> PRIMARY KEY (a)
> -> );
> Query OK, 0 rows affected (0.02 sec)
>
> mysql> INSERT INTO test (b) VALUES (1);
> Query OK, 1 row affected (0.01 sec)
>
T UNSIGNED NOT NULL,
-> PRIMARY KEY (a)
-> );
Query OK, 0 rows affected (0.02 sec)
mysql> INSERT INTO test (b) VALUES (1);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO test (b) VALUES (LAST_INSERT_ID());
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO test (b) VALUES (
> >>The only way I can debug this is if you give me a repeatable test case.
> >>Since the test case I showed you does not repeat the bug, you will need
> >>to generate a standalone test case, with schema, data, and the java code
> >>that demonstrates the issue.
> >>
> >>-Mark
> >
> >
> > Hey mark,
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Tea Yu wrote:
Not really, I substituted the queryStmt with the actual one but it gave
the
same result.
After some work:
select last_insert_id();//getInt() should return 14
//but now it gives
name
VARCHAR(255),
primary key (id));
2) here is the code segment
String insertStmt = "insert into test (name) values ('hi')";
String queryStmt = "select last_insert_id()";
try {
stmt.executeUpdate(insertStmt);
ResultSet rs = stmt.executeQuery(queryStmt);
LL AUTO_INCREMENT, name
VARCHAR(255),
> > primary key (id));
> >
> > 2) here is the code segment
> >
> > String insertStmt = "insert into test (name) values ('hi')";
> > String queryStmt = "select last_insert_id()";
>
, name varchar(255))
also tried
test (id int not null auto_increment, name varchar(255))
and did an SQLQuery thru JDBC
insert into TABLE (name) values ('test');
select last_insert_id() from TABLE;
but got the Exception
java.sql.SQLException: Invalid value for getInt() - 'q
Yea thanks for correct this, so I'm getting the right resultSet in
console...
but still having problem thru ConnectorJ, "select last_insert_id()" returns
a String to me, rs.getString(1) throws no exception.
Tea
> You don't select last_insert_id() from table.
null auto_increment, name varchar(255))
> > also tried
> > test (id int not null auto_increment, name varchar(255))
> >
> > and did an SQLQuery thru JDBC
> > insert into TABLE (name) values ('test');
> > select last_insert_id() from TABLE
You don't select last_insert_id() from table.
This will return the last_insert_id() for each row of the table.
You just select last_insert_id().
Tea Yu wrote:
>Hi! I just tried
>Windows ME + MySQL Server - 4.0.9/4.0.11 +
>ConnectorJ - 3.0.4/3.0.6/3.1.0
>
>with an In
gt; test (id int not null auto_increment, name varchar(255))
>
> and did an SQLQuery thru JDBC
> insert into TABLE (name) values ('test');
> select last_insert_id() from TABLE;
>
> but got the Exception
> java.sql.SQLException: Invalid value for getInt()
insert into TABLE (name) values ('test');
select last_insert_id() from TABLE;
but got the Exception
java.sql.SQLException: Invalid value for getInt() - 'q'
while successive running of program returns
'r', 's', 't'...
Query from console re
7;ve seen just about every question on
> last_insert_id(), except this
> one:
>
> I am running MySQL on Win XP and when I generate a
> test table (test) with an
> AUTO_INCREMENT column (aid) and a second column (a)
> then use an insert
> statement like: INSERT IN
In the last episode (Feb 01), Alan said:
> Okay, I've seen just about every question on last_insert_id(), except
> this one:
>
> I am running MySQL on Win XP and when I generate a test table (test)
> with an AUTO_INCREMENT column (aid) and a second column (a) then use
> a
Okay, I've seen just about every question on last_insert_id(), except this
one:
I am running MySQL on Win XP and when I generate a test table (test) with an
AUTO_INCREMENT column (aid) and a second column (a) then use an insert
statement like: INSERT INTO test (a) values (1); then: S
LAST_INSERT_ID is held for the database connection, not agaist the
server
So, as long as you do not do another insert using the same database
connection, LAST_INSERT_ID will be fine.
(for database connection, $dbh=DBI->connect. )
No table locking required.
Regards
M
On Wed, 18
Jeff Snoxell wrote:
> At 09:46 19/12/02 -0500, you wrote:
> >Jeff Snoxell wrote:
> >
> >>Nope. That doesn't do it either!
> >>
> >>I go:
> >>
> >>TRUNCATE TABLE my_table
> >
> >Are you using InnoDB tables? You'll have to do something akin to ALTER
> >TABLE my_table AUTO_INCREMENT=1 ... at least ac
At 15:13 + 12/19/02, Jeff Snoxell wrote:
At 09:46 19/12/02 -0500, you wrote:
Jeff Snoxell wrote:
Nope. That doesn't do it either!
I go:
TRUNCATE TABLE my_table
Are you using InnoDB tables? You'll have to do something akin to
ALTER TABLE my_table AUTO_INCREMENT=1 ... at least accordin
At 09:46 19/12/02 -0500, you wrote:
Jeff Snoxell wrote:
Nope. That doesn't do it either!
I go:
TRUNCATE TABLE my_table
Are you using InnoDB tables? You'll have to do something akin to ALTER
TABLE my_table AUTO_INCREMENT=1 ... at least according to Paul ... :)
No, I'm using MyISAM I belie
1 - 100 of 198 matches
Mail list logo