I have a Postgres enumerated type used to describe the node class (order sensitive) of a source/destination relationship table. Question is, how can I dynamically fetch the next value (if any) of an enumeration instance?
CREATE TYPE MyEnum AS ENUM ('level1', 'level2', 'level3');
SELECT dst_type, dst_id
FROM my_relationships
WHERE src_type::MyEnum = next(dst_type::MyEnum) -- does not work
-- WHERE src_type::MyEnum = dst_type::MyEnum + 1 -- does not work
AND src_id = 'd4fc1d5d-b054-d37c-4e80-2c04a6b3dbf8';
Asked by eliangius
(155 rep)
Feb 11, 2022, 02:26 AM
Last activity: Feb 11, 2022, 06:44 AM
Last activity: Feb 11, 2022, 06:44 AM