Re: catalog info for sequences - Mailing list pgsql-general

From Julio Cesar Sánchez González
Subject Re: catalog info for sequences
Date
Msg-id 47B15B8E.2020004@sistemasyconectividad.com.mx
Whole thread Raw
In response to catalog info for sequences  (Marc Munro <marc@bloodnok.com>)
List pgsql-general
Marc Munro wrote:
> Can someone please tell me how to extract the mix, max, increment by,
> etc, values for a sequence from the system catalogs.  Is this in the
> manual somewhere (I couldn't find it)?
>
> Thanks
>
> __
> Marc
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
>       subscribe-nomail command to majordomo@postgresql.org so that your
>       message can get through to the mailing list cleanly
>
try with select * from your_sequence_name;

or try next plpgsql function:


CREATE OR REPLACE FUNCTION obtenersecuencias() RETURNS void AS $$
DECLARE
    sec_names RECORD;
    row RECORD;
    secuencia refcursor;
BEGIN
    FOR sec_names IN select relname from pg_class where relkind = 'S' LOOP
        OPEN secuencia FOR EXECUTE 'SELECT * FROM ' || sec_names.relname;
        FETCH secuencia INTO row;
        CLOSE secuencia;

        RAISE NOTICE 'secuencia = %, last_val = %',row.sequence_name,
row.last_value;

    END LOOP;

END;
$$ LANGUAGE plpgsql;

--
Regards,

Julio Cesar Sánchez González.

--
Ahora me he convertido en la muerte, destructora de mundos.
Soy la Muerte que se lleva todo, la fuente de las cosas que vendran.

www.sistemasyconectividad.com.mx        http://darkavngr.blogspot.com/


pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: WINDOWS INSTALLATION TIPS
Next
From: Ivan Sergio Borgonovo
Date:
Subject: Re: end of life for pg versions...