Search Postgresql Archives

Re: catalog info for sequences

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx 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/


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

              http://www.postgresql.org/docs/faq

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux