IF EXISTS (SELECT 0 FROM pg_class where relname = '<my sequence name here>' ) THEN --stuff here END IF;