Re: Functional Indexes?
Posted in 2008
Ian Michael Gumby said: > > Ok sports fans, here's a really fun problem. > > Suppose you have a table with the following columns: > > Table Foo: > Column a: id (Integer) > Column b: type (single character) > Column c: sequence # > Column d: description (varchar up to 128 characters wide) > > Now there are 3 types of records: "A", "B","C" > > Here's where the fun begins. > > I need to ensure that if I have a record of type "C", the pair (id, type) > must be unique. > For the other record types, I need to allow for multiple entries per id. > > So how do you do this? > > The answer is create a functional index that ensures uniqueness for > records of type "C" per id. > > > I have a really cool solution in Oracle. > Now I'd like to see it in DB2 and IDS. > > So what's the syntax? I'm not sure that using a functional index is the answer, it sounds more to me like a user defined type. But I don't really understand the problem, so I'm probably wrong. :o) -- Bye now, Obnoxio "There were a myriad of problems which conspired to corrupt your reason and rob you of your common sense. Fear got the best of you, and in your panic you turned to the Labour Party. They promised you order, they promised you peace, and all they demanded in return was your silent, obedient consent."