Re: getting back autonumber just inserted

From: Mischa Sandberg <mischa(dot)sandberg(at)telus(dot)net>
To: "jimmy(dot)olsen" <jimmy(dot)olsen(at)ig(dot)com(dot)br>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: getting back autonumber just inserted
Date: 2005-07-10 01:00:36
Message-ID: 1120957236.42d07334209cd@webmail.telus.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Quoting "jimmy.olsen" <jimmy(dot)olsen(at)ig(dot)com(dot)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").

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Hayward 2005-07-10 10:52:10 function parameters : bug?
Previous Message jimmy.olsen 2005-07-09 12:59:58 Re: getting back autonumber just inserted