Thread: Re: nextval, sequences and sequencenames

Re: nextval, sequences and sequencenames

From
wsheldah@lexmark.com
Date:

I think someone pointed out not long ago that that naming convention isn't
always 100% reliable.  How about creating the sequence dynamically (using that
naming convention even), then create the table dynamically and have it
explicitly use the sequence you just created.  That way you *know* the name of
the sequence; should probably check to be sure the name isn't already in use, or
trap for errors when creating the sequence and adjust accordingly.




Gordan Bobic <gordan%bobich.net@interlock.lexmark.com> on 08/15/2001 04:14:02 AM

To:   Wieger Uffink <wieger%usmedia.nl@interlock.lexmark.com>
cc:   PostgreSQL-General <pgsql-general%postgresql.org@interlock.lexmark.com>
      (bcc: Wesley Sheldahl/Lex/Lexmark)
Subject:  Re: [GENERAL] nextval, sequences and sequencenames


On Tue, 14 Aug 2001, Wieger Uffink wrote:

> My question:
> is there anyway of retreiving the sequence_name corresponding to the
> respective column,
> knowing just the tablename and columnname?
>
> The reason I need to do this, is because the application I write
> dynamicly creates new tables, and I have no way of knowing the sequence
> name before hand.
>

Try "tablename_fieldname_seq". That is the default sequence name for a
"serial" field.

Cheers.

Gordan


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html