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----- From: Daniel Kasak [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 15, 2004 12:42 AM To: [EMAIL PROTECTED] Subject: DBI and last_insert_id() 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 special > variable $@ > if ($@) { > > # Dialog explaining error... > my $dialog = &msgbox( > $prospects->get_widget("Prospects"), > "Error updating recordset!", > "Database Server says:\n" . $dbh->errstr, > 1 > ); > > $dialog->run; > $dialog->destroy; > > warn "Error updating recordset:[EMAIL PROTECTED]" . $@ . > "\n\n"; > > return 0; > > } > > > $pk = $dbh->last_insert_id(); The statement executes successfully, and the data is inserted. However the above line that fetches the last_insert_id value from MySQL always returns undef. The table has an auto_increment column. What's going on? Dan -- Daniel Kasak IT Developer NUS Consulting Group Level 5, 77 Pacific Highway North Sydney, NSW, Australia 2060 T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989 email: [EMAIL PROTECTED] website: http://www.nusconsulting.com.au -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]