Re: SERIAL Field - Mailing list pgsql-admin

From Rajesh Kumar Mallah.
Subject Re: SERIAL Field
Date
Msg-id 200205061856.10924.mallah@trade-india.com
Whole thread Raw
In response to SERIAL Field  ("Gaetano Mendola" <mendola@bigfoot.com>)
Responses Re: SERIAL Field
List 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.



pgsql-admin by date:

Previous
From: "Joel Burton"
Date:
Subject: Re: SERIAL Field
Next
From: Tom Lane
Date:
Subject: Re: Dying PostgreSQL backend