in reply to Re: Finding value of primary key (autoincrement) from last-inserted row with DBIx::Abstract and postgresql
in thread Finding value of primary key (autoincrement) from last-inserted row with DBIx::Abstract and postgresql

Thanks for the quick reply. Hopefully I'm not being too dense here, but how would I implement the CURVAL() SELECT in the same transaction as the INSERT, using DBIx::Abstract? If I do SELECT curval() immediately after the INSERT (in the next line of perl), there is of course a small chance that another instance of the script will have done an INSERT in the interim. (Scaled up enough, presumably that is sure to happen). Or do I need to do send an "unmediated" SQL statement to the DB handle that just does the INSERT and then the SELECT? Even if that case, isn't there chance that another INSERT from another instance gets in before the SELECT?
  • Comment on Re^2: Finding value of primary key (autoincrement) from last-inserted row with DBIx::Abstract and postgresql

Replies are listed 'Best First'.
Re^3: Finding value of primary key (autoincrement) from last-inserted row with DBIx::Abstract and postgresql
by roboticus (Chancellor) on Jun 19, 2006 at 03:03 UTC
    I just looked at the package, and I'm not so sure. I see the commit and rollback functions, but I can't seem to find a begin transaction function. Perhaps the query method would let you put the insert and select in the same statement. I use the DBI package, rather than DBIx, so I'm just guessing.

    --roboticus