9 messages in com.mysql.lists.mysqlRe: last_inserted_id| From | Sent On | Attachments |
|---|---|---|
| Monika Plawna | 12 Apr 2000 11:07 | |
| Matt Levine | 12 Apr 2000 11:22 | |
| Monika Plawna | 12 Apr 2000 11:47 | |
| Robert Goff | 12 Apr 2000 12:07 | |
| Sam Mefford | 12 Apr 2000 12:19 | |
| Monika Plawna | 12 Apr 2000 12:35 | |
| Monika Plawna | 12 Apr 2000 13:22 | |
| Thimble Smith | 13 Apr 2000 02:20 | |
| Monika Plawna | 13 Apr 2000 09:56 |
| Subject: | Re: last_inserted_id![]() |
|---|---|
| From: | Monika Plawna (pla...@nortelnetworks.com) |
| Date: | 04/12/2000 12:35:36 PM |
| List: | com.mysql.lists.mysql |
Robert,
I was starting to suspect that's what was happening, thank you for timely confirmation. The prepare, execute and fetch statements work great now.
I gave the $insertId = $dbh->{'mysql_insertid'} a shot, but it returned no value. It generated no error either. Although I managed to get it working using the other method, my curiousity is getting the better of me, I think. So if anyone has any ideas as to why it might not work, please share! Thanks again to Rob!
Monika
Robert Goff wrote:
- my $req_id = $dbh ->do ('select last_insert_id()'); - - right after I perform an insert. I check the tables manually and the - entries get inserted properly, but the above statement always returns 1.
You're getting the status of the operation, not the value of the statement. 'do' doesn't return a value, just a status. You'll have to go through the prepare, execute, fetch sequence if you want to use the select statement.
Or you could use the db handle attribute: The DBD::mysql driver supports the following attributes of database handles (read only):
$infoString = $dbh->{'info'}; $threadId = $dbh->{'thread_id'}; $insertId = $dbh->{'mysql_insertid'}
These correspond to mysql_info(), mysql_thread_id() and mysql_insertid(), respectively.
-- Only in America do we leave cars worth thousands of dollars in the driveway and put our useless junk in the garage. =============================================== Robert Goff bea...@avalon.albuquerque.nm.us Technical Writer/Editor, Webmaster 505-564-8959
--
Monika Plawna Service Builder Lab Support ESN 395-5257 (613) 765-5257




