The two easy ways to do this with Postgres. One is to specify the ID col. as
serial type, which will cause it to be auto-incrementing (i.e. when you insert a row, it will automagically get a new, unique val in the serial col).
Additionally, you can use a postgres sequence to keep track of
the ID, and query it with postgres's nextval function whenever you need a new value:
my $sth=$dbh->prepare("select nextval(?)");
$sth->execute("seq_name");
my $id=$sth->fetchrow();
$sth->finish();
Of coruse, you can also do this the
old-school way too (but its less efficient to do it this way):
Have a table to store the last assigned ID. When you need an ID, lock that table, read the value out of it, write the value+1 back to the table, and then unlock it.