in reply to Autoincrement and server hostname in DB2

Okay, a co-worker of mine finally tracked down the answer. Just posting here in case any one else is interested in the answer:

  1. Turn off auto-commit ($dbh->{'AutoCommit'} = 0)
  2. Do insert
  3. SELECT id FROM table WHERE id = INTEGER(IDENTITY_VAL_LOCAL())
  4. Commit changes

Naturally, id is the field that is auto-incremented and table is the table you just inserted into.

Share and Enjoy.

  • Comment on Re: Autoincrement and server hostname in DB2