If you've got transactions, why not create a table of primary keys? Seems the most straightforward mechanism, and can be written in standard SQL so its portable across databases.
If you've not got transactions I've found DBIx::Sequence useful.
You might also find this discussion of interest.
In reply to Re: Generating portable SQL primary key sequences
by adrianh
in thread Generating portable SQL primary key sequences
by tachyon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |