Wednesday, March 7, 2012

Assign different property to node and keep the value as it is


Although same can be done by updating property name directly if the old property is not required at all.


Backup table created as
CREATE TABLE CZ_PS_PROP_VALS_BKUP_6MAR12 AS SELECT * FROM CZ_PS_PROP_vALS;


Current count of this property usage of our models in RMT%In%Process folder

SELECT count(*), P.NAME
FROM cz_ps_prop_vals V, CZ_PROPERTIES P
WHERE P.deleted_flag=0
AND V.DELETED_FLAG=0
AND V.PROPERTY_ID = P.PROPERTY_ID
AND P.name like '%OFFERING%'
AND V.ps_node_id   IN
  (SELECT ps_node_id
  FROM cz_ps_nodes
  WHERE deleted_flag=0
  and devl_project_id IN
    (SELECT object_id
    FROM cz_rp_entries
    WHERE enclosing_folder = 136906
    AND deleted_flag       =0
    )
    )
  GROUP BY P.NAME;



Update query executed to update 394 rows
UPDATE CZ_PS_PROP_VALS
SET PROPERTY_ID = 5302 -- MYOFFERING
WHERE PROPERTY_ID = 5522 --YOUROFFERING
AND DELETED_FLAG=0
AND PS_NODE_ID IN (SELECT ps_node_id
  FROM cz_ps_nodes
  WHERE deleted_flag=0
  and devl_project_id IN
    (SELECT object_id
    FROM cz_rp_entries
    WHERE enclosing_folder = 136906
    AND deleted_flag       =0
    )
    );

No comments:

Post a Comment