I’m trying to test, within a stored procedure, whether a sequence already exists.
IF EXISTS SEQUENCE seq_name
RAISE EXCEPTION 'sequence % already exists!', seq_name
END IF;
I have tried several variations of the snippet above without luck. I must be giving Google the wrong terms because I can’t seem to find anything on the topic. Any help is appreciated!
You should be able query the pg_class table to see if the relname exists.