Re: SERIAL Field

From: "Rajesh Kumar Mallah(dot)" <mallah(at)trade-india(dot)com>
To: "Gaetano Mendola" <mendola(at)bigfoot(dot)com>, <pgsql-admin(at)postgresql(dot)org>
Subject: Re: SERIAL Field
Date: 2002-05-06 13:26:10
Message-ID: 200205061856.10924.mallah@trade-india.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi Gaetano,

Postgresql implements serial field using sequences.

detailed description of sequences are avaliable at
http://www.postgresql.org/idocs/index.php?functions-sequence.html

a NICE flash tutorial is also available at:
http://techdocs.postgresql.org/college/001_sequences/

the specific answer to your question is the function "currval(sequence_name)"
can be used.
you can get the name of sequenced being used for the serial field by
describing the table (\d tablename).

But the very idea of inserting the value and then retriving the sequence
number sounds fishy to me. Why not get the sequence number first and than
insert using that seqnce number (more on the flash tutorial ).

regds
mallah.

On Monday 06 May 2002 04:16 pm, Gaetano Mendola wrote:
> Hi all,
>
> having a table with a serial field what is the corrected method
> to retrieve the value after an insert ?
>
>
>
>
> Ciao
> Gaetano

--
Rajesh Kumar Mallah,
Project Manager (Development)
Infocom Network Limited, New Delhi
phone: +91(11)6152172 (221) (L) ,9811255597 (M)

Visit http://www.trade-india.com ,
India's Leading B2B eMarketplace.

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2002-05-06 13:45:31 Re: Dying PostgreSQL backend
Previous Message Joel Burton 2002-05-06 12:38:46 Re: SERIAL Field