On Monday 19 November 2001 20:27, Vincent Ma wrote:
> Hi everybody:
> I would like to ask why the error occur when retrieve current sequence
> number. Eg. "select currval('student_id_seq')" is not working, and warning
> prompt "student_id_seq.currval is not yet defined in this session".
> However, this is work for the "select nextval()";
> do anyone know how to get current sequence number, in php. Thank for your
> Vincent Ma
The problem here is that it looks like you have NOT inserted a record into
the DB yet, therefore, you don't have a current value to get.
currval gets the last inserted id number for this connection. nextval will
get the value that will be used next.
If you are trying to get a id number for insertion (i.e. not using the
automatic insert) that nextval is the one you should use.
NOTE: If you are using transactions and do a rollback, you will have holes
in your sequences.
Hope this helps.
GB Clark II | Roaming FreeBSD Admin
[EMAIL PROTECTED] | General Geek
CTHULU for President - Why choose the lesser of two evils?
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]