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

Re: currval() within one statement

From: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
To: sad <sad(at)bankir(dot)ru>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: currval() within one statement
Date: 2008-01-22 09:13:26
Message-ID: 4795B3B6.5040004@lelarge.info (view raw or flat)
Thread:
Lists: pgsql-sql
sad wrote:
> A. Kretschmer wrote:
> 
>>> is it expected that the currval() changes its value between calls 
>>> within one statement ?
> 
>> Conclusion, don't call nextval() within a TRIGGER, and insert either
>> nextval() for the column or omit this column.
> 
> I only note that i still want to discuss the titled problem or to be
> given an exact pointer to documentation regarding the currval() behavior
> in the described situation, that i had.
> 

Well, your situation is weird, to say the least. currval() doesn't 
change the value of a sequence. Adding a trigger that calls nextval() 
will change the value. But you're not telling us which kind of 
trigger... per statement or for each row ? if it's for each row, then 
that's quite understandable.

BTW, sequence functions are described here :
   http://www.postgresql.org/docs/8.2/interactive/functions-sequence.html

Regards.


-- 
Guillaume.
  http://www.postgresqlfr.org
  http://dalibo.com

In response to

Responses

pgsql-sql by date

Next:From: Richard HuxtonDate: 2008-01-22 09:13:56
Subject: Re: currval() within one statement
Previous:From: Stuart BrooksDate: 2008-01-22 08:05:04
Subject: TIMESTAMP comparison problem

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