Re: newid() in postgres - Mailing list pgsql-general

From Postgres User
Subject Re: newid() in postgres
Date
Msg-id b88c3460704042024n497f18edxca83d11b8558f6e2@mail.gmail.com
Whole thread Raw
In response to Re: newid() in postgres  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: newid() in postgres  ("marcel.beutner" <m.beutner@googlemail.com>)
List pgsql-general
Marcel,

A sequence represents a unique identifier. You can call the function
'nextval' to get the next unique value in the sequence.  See related
functions here:

http://www.postgresql.org/docs/8.2/interactive/functions-sequence.html

In this code, I get the next sequence, insert it into a table, and
then return the value to the calling function:

DECLARE
     nextseq integer;

BEGIN
    nextseq := nextval('entry_id_seq');

    INSERT INTO my_table (
        entry_id,
        entry_text,
    ) VALUES (
        nextseq,
        p_entry_text,  -- input param
    );

On 4/4/07, Peter Eisentraut <peter_e@gmx.net> wrote:
> marcel.beutner wrote:
> > I've searched in the groups already, but couldn't find any helpful
> > information - only to use a sequence, which returns just a number and
> > not a unique identifier.
>
> Which properties do your unique identifiers posses that are not
> satisfied by a number returned by a sequence?
>
> --
> Peter Eisentraut
> http://developer.postgresql.org/~petere/
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
>               http://www.postgresql.org/docs/faq
>

pgsql-general by date:

Previous
From: "Harvey, Allan AC"
Date:
Subject: Re: Storing blobs in PG DB
Next
From: "Postgres User"
Date:
Subject: Re: Need your help on using "partion"