pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Achilleus Mantzios <achill@matrix.gatewaynet.com>
To: ow <oneway_111@yahoo.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: currval() without specifying the sequence name
Date: Tue, 9 Mar 2004 17:09:47 +0200 (EET)
Message-ID: <Pine.LNX.4.44.0403091705490.32587-100000@matrix.gatewaynet.com> (raw)
In-Reply-To: <20040309145359.79236.qmail@web60805.mail.yahoo.com>

O kyrios ow egrapse stis Mar 9, 2004 :

> 
> --- Achilleus Mantzios <achill@matrix.gatewaynet.com> wrote:
> > 
> > You could use the same sequence in many tables.
> > 
> 
> I guess I could but then:
> 
> 1) I'd still have to know the sequence name. When integrating pgSql with 3party
> frameworks I'd either have to pass it there (could be a very difficult task) or
> make some assumptions (also not very good).
> 
> 2) There may be a need to have different sequences being used in an app.
> 
> 3) If one sequence is used, in many cases it'll have to be of type int8 and
> pgSql does not handle searches with int8 very nicely.
> 
> Thanks
> 
>

I dont think you have given solid reasons as to why somebody whould
want to do that (in order to be more specific and help you better),
but in any case:

foodb=# SELECT relname from pg_class where relkind = 'S';
    relname
---------------
 footbl_id_seq
 footbl2_id_seq
(1 row)

gives you a list of sequences of your current schema.

Then you can loop thru those to:

select last_value from <cur_seq>;
and get the maximum, but again what exaclty are you trying to do?
 
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Search - Find what you’re looking for faster
> http://search.yahoo.com
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
> 

-- 
-Achilleus




view thread (7+ messages)  latest in thread

Message-ID: <Pine.LNX.4.44.0403091705490.32587-100000@matrix.gatewaynet.com>
Permalink:  ../Pine.LNX.4.44.0403091705490.32587-100000@matrix.gatewaynet.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.44.0403091705490.32587-100000@matrix.gatewaynet.com

 · 

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: achill@matrix.gatewaynet.com, oneway_111@yahoo.com
  Subject: Re: currval() without specifying the sequence name
  In-Reply-To: <Pine.LNX.4.44.0403091705490.32587-100000@matrix.gatewaynet.com>

* 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