Friday, November 25, 2011

How to change a single attribute to repeating

There's no direct way to change a single attribute to repeating in your custom types, so this task is not trivial if you already have objects with metadata that should be preserved: a temporary attribute must be used.
The safe way is to perform the following steps:


1. Ensure no objects of your type are locked: select * from my_type where r_lock_owner <> ' ' (if you have locked objects, you should unlock them - see how to unlock).
2. Create a temporary single attribute fake_attr: alter type my_type add fake_attr char(100) publish
3. Copy all the values from your single attribute to the temporary one: update my_type objects set fake_attr=my_attr
4. Remove the single attribute: alter type my_type drop my_attr publish
5. Add the repeating attribute: alter type my_type add my_attr char(100) repeating publish
6. Copy back the metadata: update my_type objects append my_attr=fake_attr

No comments:

Post a Comment