pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mischa Sandberg <mischa.sandberg@telus.net>
To: jimmy.olsen <jimmy.olsen@ig.com.br>
Cc: pgsql-sql@postgresql.org
Subject: Re: getting back autonumber just inserted
Date: Sat,  9 Jul 2005 18:00:36 -0700
Message-ID: <1120957236.42d07334209cd@webmail.telus.net> (raw)
In-Reply-To: <007901c58486$5a973430$230a0a0a@ligaone.com.br>
References: <42CD6B58.6060508@techevolution.be>
	<20050707180329.GA11332@alvh.no-ip.org>
	<007901c58486$5a973430$230a0a0a@ligaone.com.br>

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").





view thread (30+ messages)  latest in thread

Message-ID: <1120957236.42d07334209cd@webmail.telus.net>
Permalink:  ../1120957236.42d07334209cd@webmail.telus.net/
Also on:    postgresql.org/message-id/1120957236.42d07334209cd@webmail.telus.net

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mischa.sandberg@telus.net, jimmy.olsen@ig.com.br
  Subject: Re: getting back autonumber just inserted
  In-Reply-To: <1120957236.42d07334209cd@webmail.telus.net>

* 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