Re: getting back autonumber just inserted - Mailing list pgsql-sql

From Mischa Sandberg
Subject Re: getting back autonumber just inserted
Date
Msg-id 1120957236.42d07334209cd@webmail.telus.net
Whole thread Raw
In response to Re: getting back autonumber just inserted  ("jimmy.olsen" <jimmy.olsen@ig.com.br>)
List pgsql-sql
Quoting "jimmy.olsen" <jimmy.olsen@ig.com.br>:

> I don't know how to create a Global Variable in Postgres, but the
> idea is
> very simple:
> 1. Encapsulate the NextVal function in MyNextVal
> 2. Set to Global variable with NextVal of the desired sequence
> 3. Inspect to value of the global variable (exactally as it's done in
> MsSQL)

Not sure if this thread is about global variables or just how to use
sequences, but ... if you want variables that are global, you can use a
table (global to all processes), a temp table (global to everything
inside one connection), or a row in a global table (can be either). I
tend to keep one global table of (key,value) pairs, with a primary key
constraint so that the query optimizer knows that "SELECT val FROM Env
WHERE key='xxx'" will return at most 1 row. The "keys" are actually
structured paths ("mail.process.thread_limit").




pgsql-sql by date:

Previous
From: "jimmy.olsen"
Date:
Subject: Re: getting back autonumber just inserted
Next
From: Harald Fuchs
Date:
Subject: Re: Make COUNT(*) Faster?