Re: Fw: postgresql experts please help - Mailing list pgsql-jdbc

From Josh Berkus
Subject Re: Fw: postgresql experts please help
Date
Msg-id 200710181257.37449.josh@agliodbs.com
Whole thread Raw
In response to Re: Fw: postgresql experts please help  (Kris Jurka <books@ejurka.com>)
Responses Re: Fw: postgresql experts please help  (Kris Jurka <books@ejurka.com>)
List pgsql-jdbc
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

pgsql-jdbc by date:

Previous
From: Kris Jurka
Date:
Subject: Re: Fw: postgresql experts please help
Next
From: Kris Jurka
Date:
Subject: Re: Fw: postgresql experts please help