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

Re: Nextval & Currval

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Nextval & Currval
Date: 2008-06-10 10:29:51
Message-ID: 20080610102951.GD25980@a-kretschmer.de (view raw or flat)
Thread:
Lists: pgsql-sql
am  Tue, dem 10.06.2008, um 11:56:39 +0200 mailte Shavonne Marietta Wijesinghe folgendes:
> Hello
>  
> I'm using Nextval and Currval in my ASP programme. But everytime i run the code
> only the nextval record is inserted and the currval record is lost. I wrote the
> INSERT INTO in the log and when i tried it via pgadmin both the records were
> inserted correctly, so there is no syntax error.
> I thought the problem would be the connection to the DB. I connect to the DB in
> the same ASP page where I do the INSERT INTO.
>  
> What am i doing wrong?? Any ideas anyone??

I don't know your code, but nextval() returns the next sequence number
from a sequence and currval() returns the last with nextval() generated
sequence-number WITHIN THIS SESSION.


In a new session you can't use currval() first, you need to call
nextval() and later you can use currval().



Regards, Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

In response to

pgsql-sql by date

Next:From: Shavonne Marietta WijesingheDate: 2008-06-10 10:35:20
Subject: Re: Nextval & Currval
Previous:From: Shavonne Marietta WijesingheDate: 2008-06-10 09:56:39
Subject: Nextval & Currval

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