nextval/dbi question

From: harrold(at)sage(dot)che(dot)pitt(dot)edu
To:
Cc: Pgsql Novice <pgsql-novice(at)postgresql(dot)org>
Subject: nextval/dbi question
Date: 2001-08-05 20:55:59
Message-ID: Pine.LNX.4.21.0108051648180.4939-100000@sage.che.pitt.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

hey.

i'm using dbi in perl to access a table whos primary key is a serialized
variable. i want to preform an insert on the table and i want the value of
the key associated with that insert.

this is what i'm doing:
# i get the new value like this:
select nextval('testtable_the_key_seq');

#and then i preforme the insert like this:
insert into testtable (an_id, timestamp) values (2, 2);

what results.

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).

thanks
john

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Francisco Reyes 2001-08-05 22:04:22 Re: Indeces vs small tables
Previous Message Tom Lane 2001-08-05 20:35:11 Re: Indeces vs small tables