Search Postgresql Archives

Re: newid() in postgres

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx> 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



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux