Skip site navigation (1) Skip section navigation (2)

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: (view raw or whole thread)
Lists: pgsql-novice

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?

Carol Walter


pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group