Kris,
> If you have an after trigger on the table that you're inserting into and
> it inserts into another table with a serial column, the lastval call will
> use the wrong sequence. Now this is also a problem with currval if you
> have a trigger that inserts into the same table, but that's an unlikely
> application design. Inserting into another table is something that you'll
> find with systems that do auditing or sometimes horizontal partitioning of
> a table.
I'm pretty sure there's a version of lastval() which takes the table name as a
parameter. That would be the safer one to use.
--
Josh Berkus
PostgreSQL @ Sun
San Francisco