Re: determine sequence name for a serial

Поиск
Список
Период
Сортировка
От Ed L.
Тема Re: determine sequence name for a serial
Дата
Msg-id 200410281651.05555.pgsql@bluepolka.net
обсуждение исходный текст
Ответ на Re: determine sequence name for a serial  (Robby Russell <robby@planetargon.com>)
Ответы Re: determine sequence name for a serial  (Robby Russell <robby@planetargon.com>)
Re: determine sequence name for a serial  (Jonathan Daugherty <cygnus@cprogrammer.org>)
Re: determine sequence name for a serial  (Michael Fuhr <mike@fuhr.org>)
Re: determine sequence name for a serial  (Greg Stark <gsstark@mit.edu>)
Список pgsql-general
On Thursday October 28 2004 11:42, Robby Russell wrote:
>
> Thanks, this seems to work well. My goal is to actually create a php
> function that takes a result and returns the insert_id like
> mysql_insert_id() does, but without needing to know the sequence names
> and such. I would make a psql function, but I don't always have that
> option with some clients existing systems.

An alternative is to simply select nextval() from a separately-created
sequence object to get the serial value, then insert with that value.  No
need to have a serial column then, but you do need to explicitly create the
sequence object, as opposed to SERIAL.

But I didn't understand why you care to get rid of the explicit reference to
the sequence object in your code in the first place.  In PostgreSQL, at
least for the past 5 years if not longer, if you create a SERIAL column for
(schemaname, tablename, columnname), then your sequence will *always* be
"schemaname.tablename_columnname_seq".  If that naming convention changes,
there will be a whole lotta breakage world-wide.

Ed


В списке pgsql-general по дате отправления:

Предыдущее
От: "Jim C. Nasby"
Дата:
Сообщение: Re: Reasoning behind process instead of thread based
Следующее
От: Robby Russell
Дата:
Сообщение: Re: determine sequence name for a serial