deduce sequence name from table and column

Started by Louis-David Mitterrandover 20 years ago3 messagesgeneral
Jump to latest
#1Louis-David Mitterrand
vindex@apartia.org

Hi,

Is there a way (from DBI) to deduce a sequence name from the table and
column it is attached to?

For instance:

Column | Type | Modifiers
-------------+---------+--------------------------------------------------------------------------
id_fonction | integer | not null default nextval(('"fonction_id_fonction_seq"'::text)::regclass)

I'd like to be able to programmatically find "fonction_id_fonction_seq"
so that I can then call nextval() on it.

Thanks,

--
Only half the people in the world are above average intelligence.

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Louis-David Mitterrand (#1)
Re: deduce sequence name from table and column

Louis-David Mitterrand <vindex@apartia.org> writes:

Is there a way (from DBI) to deduce a sequence name from the table and
column it is attached to?

Since 8.0 you can use pg_get_serial_sequence(), see
http://www.postgresql.org/docs/8.0/static/functions-info.html

regards, tom lane

#3Louis-David Mitterrand
vindex@apartia.org
In reply to: Tom Lane (#2)
Re: deduce sequence name from table and column

On Tue, Dec 20, 2005 at 10:31:46AM -0500, Tom Lane wrote:

Louis-David Mitterrand <vindex@apartia.org> writes:

Is there a way (from DBI) to deduce a sequence name from the table and
column it is attached to?

Since 8.0 you can use pg_get_serial_sequence(), see
http://www.postgresql.org/docs/8.0/static/functions-info.html

Just what I needed,
Thanks!

--
-= this .sig is not funny =-