in reply to Unique ID
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:
Of coruse, you can also do this the old-school way too (but its less efficient to do it this way):my $sth=$dbh->prepare("select nextval(?)"); $sth->execute("seq_name"); my $id=$sth->fetchrow(); $sth->finish();
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Unique ID
by nlafferty (Scribe) on Jul 19, 2001 at 21:05 UTC | |
by lhoward (Vicar) on Jul 19, 2001 at 21:28 UTC |