$dbh->last_insert_id() not working

From: Daniel Kasak (dkasak_at_nusconsulting.com.au)
Date: 06/17/04

  • Next message: Karl: "Help fixing tricky SQL statement requested"
    Date: Thu, 17 Jun 2004 12:06:29 +1000
    To: dbi-users@perl.org
    
    
    

    Hi all.

    I'm using DBI-1.42, Perl-5.8.4, MySQL-4.0.18 and DBD::MySQL-2.9003.
    I'm trying to get the ID of the last inserted record.

    I can use:

    > $dbh->{'mysql_insertid'}

    and it returns the correct value, however if I change the above to:

    > $dbh->last_insert_id()

    it doesn't work. It returns undef.
    I'd like to use last_insert_id() because I want to be able to use this
    bit of code to handle updates with different databases.

    What's up?

    -- 
    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: dkasak@nusconsulting.com.au
    website: http://www.nusconsulting.com.au
    

  • Next message: Karl: "Help fixing tricky SQL statement requested"

    Relevant Pages

    • Detect platform
      ... NUS Consulting Group ... Level 5, 77 Pacific Highway ... North Sydney, NSW, Australia 2060 ...
      (perl.beginners)
    • Re: $dbh->last_insert_id() not working
      ... I'm having a similar problem...anyone have a resolution? ... > I'm trying to get the ID of the last inserted record. ... > NUS Consulting Group ... > Level 5, 77 Pacific Highway ...
      (perl.dbi.users)