pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rajesh Kumar Mallah. <mallah@trade-india.com>
To: Gaetano Mendola <mendola@bigfoot.com>
To: pgsql-admin@postgresql.org
Subject: Re: SERIAL Field
Date: Mon, 6 May 2002 18:56:10 +0530
Message-ID: <200205061856.10924.mallah@trade-india.com> (raw)
In-Reply-To: <002901c1f4eb$40cbe240$d5a9fea9@GMENDOLA2>
References: <002901c1f4eb$40cbe240$d5a9fea9@GMENDOLA2>

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.





view thread (12+ messages)  latest in thread

Message-ID: <200205061856.10924.mallah@trade-india.com>
Permalink:  ../200205061856.10924.mallah@trade-india.com/
Also on:    postgresql.org/message-id/200205061856.10924.mallah@trade-india.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: mallah@trade-india.com, mendola@bigfoot.com
  Subject: Re: SERIAL Field
  In-Reply-To: <200205061856.10924.mallah@trade-india.com>
  References: <002901c1f4eb$40cbe240$d5a9fea9@GMENDOLA2> <200205061856.10924.mallah@trade-india.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox