Re: Insert Data and autonumeric field

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: André José Guergolet <AGuergolet(at)compugraf(dot)com(dot)br>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Insert Data and autonumeric field
Date: 2007-02-01 18:32:19
Message-ID: 20383.1170354739@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

=?iso-8859-1?Q?Andr=E9_Jos=E9_Guergolet?= <AGuergolet(at)compugraf(dot)com(dot)br> writes:
> INSERT INTO table1 (date, field2, field3) VALUES (now,'value2','value3');
> SELECT last_value FROM seq_table1;

You should never ever look directly at the sequence table (except
perhaps for manual debugging purposes). I think you may have confused
this with use of the lastval() function --- currval() or sometimes
lastval() are the appropriate way to get the last-assigned value.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Andrew Sullivan 2007-02-01 18:53:16 Re: Differentiate Between Zero-Length String and NULLColumn Values
Previous Message Andrew Sullivan 2007-02-01 18:13:05 Re: Insert Data and autonumeric field