Resources are unable to be saved after using SQL to change a custom data class

Article:TECH198194  |  Created: 2012-10-10  |  Updated: 2012-10-10  |  Article URL http://www.symantec.com/docs/TECH198194
Article Type
Technical Solution


Issue



A custom data class with one or more attributes was created and then assigned to a resource, such as Computers. Later, it is determined that one of the data class attributes (its fields) are no longer desired, or, changes to its structure are desired (such as changing the maximum length of a string attribute). As committed data classes are unable to be edited for the most part using the CMDB user interface, the user changes this manually using SQL Server Management Studio. Afterwards, the resources that have data in the deleted/modified attribute can no longer be edited and/or saved.


Cause



The metadata was not changed when the the data class was manually changed in SQL.


Solution



Edit the custom data class in the CMDB user interface by simply clicking on its "Save changes" button. This resaves the metadata with the current values, which should then enable editing of old resources and remove/change the affected fields.

Warnings:

(1) As this was caused by an unsupported manual SQL change, this may have caused severe issues with the database. If resaving the data class does not resolve the issue, the user may need to restore the database from a backup.

(2) It is strongly recommended that users carefully consider how they want their custom data classes to work before committing them to the database as this makes permanent changes. This has the potential to be a serious impact on the database depending on how the data classes are used in the system.

(3) If the user wants to, at their own risk, perform manual changes, it is strongly recommended to back up the database first, or if this cannot be done, at least back up the Inv_<custom data class_name> table before making changes.

Additional solution

If resaving the data class does not resolve the issue and the database or table cannot be resolved, it's possible that the data class will need to be recreated. This can be done by doing the following:
 

  1. Create a new custom data class with the now desired attributes.
  2. In SQL, write a script to copy data from the old data class to the new data class, skipping any deleted fields as necessary. For example,

    USE Symantec_CMDB
    INSERT INTO Inv_New_Custom_Data_Class_Name
    SELECT _ResourceGuid, <other fileds to copy as well> -- Do not copy the _id field, as this is a unique field and will not be able to be copied.
    FROM Inv_Old_Custom_Data_Class_Name

    Note: Please contact your DBA for assistance in using or modifying the above SQL script to be usable with the custom data classes involved.
     
  3. In CMDB, remove the old custom data class from being assigned to the resource, then add the new one.
  4. The old one can now be deleted under Data Classes.
  5. The only difference now is the changes as defined by the new custom data class, and its new name. Editing resources that had the old data class should now have the copied new data class values.

 




Article URL http://www.symantec.com/docs/TECH198194


Terms of use for this information are found in Legal Notices