check sequence in postgresql code example
Example 1: check current sequence value postgres
SELECT last_value FROM sequence_name;
Example 2: how to check if a sequence exists in postgresql
IF EXISTS (SELECT 0 FROM pg_class where relname = '<my sequence name here>' )
THEN
--stuff here
END IF;