> mitch and all, i've developed a simple little script
> in order to test the "last id" methodology mitch
> suggested.
>
> it looks like this... php and adodb include
> excluded
> for brevity...
>
> -----
> $db = &ADONewConnection('postgres7');
> $db ->
> Connect($db_string,$db_owner,$db_pw,$db_name);
> $insert_id = $db->getone("select
> nextval('public.customer_cust_id_seq')");
>
> print 'The ID is ' . $insert_id;
> -----
>
> my sequence name is 'public.customer_cust_id_seq'
> (found this in pgadmin3).
>
> the last id number in my table is 65. when i use
> nextval(), i get a result of 66 for $insert_id -
> which
> is the value that i would want to then perform and
> insert.
>
> however, when i use currval(), as recommended, i get
> no result. i probably get an error, but i haven't
> checked for that yet.
>
> is it OK to use nextval() to get the next id value
> in
> the sequence before doing an insert? how come
> currval() doesn't work.
>
> thanks to all for any guidance here.
mitch and all, i noticed that if i keep refreshing my
page that the $insert_id keeps growing... 66 then 67
then 68 then 69.
i guess this makes sense, after all, the "next value"
is always and icnrement higher. this makes me a
little nervous, though.
i only want one value... the next id i should use to
perform an insert.
i'm hoping currval() does the trick, however, i'm
getting no result.
do i need to instruct the sequence to go to it last
value before calling currval()?
tia...
__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail