Sorry about the rubbish question title. I have a table SET_DEFINITIONS
like this:
SETKEY NOT NULL NUMBER(38)
SETENTRY NOT NULL NUMBER(38)
where the idea is that the rows define sets of numbers. For example the table could contain rows:
1 2
1 4
2 1
2 2
which would mean set 1 is {2,4} and set 2 is {1,2}. I want to write a function
function selectOrInsertSet(table of number(38) numbers) return number(38)
which will return the key of a set with the same members as the passed in table (or create such a set if it doesn't exist). What's a good way to do this in PL/SQL?
EDIT: the solution I'm currently working on goes like this (and I'm not sure it'll work):
- select all keys that have the first element into some collection c
- refine the collection c by intersecting with successive sets of keys that contain the other elements