On Monday 06 August 2001 06:55, you wrote:
> this is what i'm doing:
> # i get the new value like this:
> select nextval('testtable_the_key_seq');
you are not assigning it to any variable?
> #and then i preforme the insert like this:
> insert into testtable (an_id, timestamp) values (2, 2);
I assume that an_id is not your primary key?
> say the last value of the sequence is 'n-1' so the select nextval
> statement above will return 'n' but when i preform the insert the value of
> testtable.the_key is actually 'n+1'. should i wrap the insert up into a
> transaction? any help would be most appreciated.
> i dont know if this is relevent but in perl i'm preparing the statement by
> using (?,?) and place holders for the (2,2).
Why do you call nextval? If your key attribute is "serial", postgres calls
nextval for you autiomatically. Thus, you call it once and postgres calls it
once, hence an increment of 2
In response to
pgsql-novice by date
|Next:||From: harrold||Date: 2001-08-05 22:47:22|
|Subject: Re: nextval/dbi question|
|Previous:||From: Francisco Reyes||Date: 2001-08-05 22:15:45|
|Subject: Re: select vs varchar|