currval, lastval, nextvar?

From: Carol Walter <walterc(at)indiana(dot)edu>
To: pgsql-novice(at)postgresql(dot)org
Subject: currval, lastval, nextvar?
Date: 2009-04-23 14:24:26
Message-ID: E38AF20C-A2CB-4E7C-8CDA-AD06C35E61D0@indiana.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hello,

I want write a query that will insert a record in a person table,
insert a record in a presentation table, and then insert a record into
a bridge table that contains the keys of both of the newly created
records from the other two tables. According to the documentation,
takes the next number in the sequence and reports it. Both currval
and lastval report the last value that was taken from the sequence,
but both will produce errors if a "nextval" was not called in the
current session. Does writing a record that automatically updates a
sequence count as calling nextval?

Thanks,
Carol Walter

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message johnf 2009-04-23 15:37:57 Re: currval, lastval, nextvar?
Previous Message Robert Campbell 2009-04-23 13:46:19 Re: Workaround for bug #4608?