Saturday, November 30, 2013

Update Java Extension ClassName for Configurator CX rules using query

Following query will update the java classname (from xxcz.cx.MyOldClass to xxcz.cx.MyNewClass ) for all the models which are under repository folder name 'Models - In Process'

UPDATE cz_rules ru
SET ru.class_name        = 'xxcz.cx.MyNewClass'
WHERE exists(SELECT
  rpf.name folder_name,
  p.name model_name,
  p.devl_project_id,
  r.name rule_name,
  r.rule_id,
  r.class_name
FROM cz_rules r,
  cz_devl_projects p,
  cz_rp_entries rpp,
  cz_rp_entries rpf
WHERE r.devl_project_id=p.devl_project_id
AND r.rule_type = 300 -- CX rules
AND rpp.object_id       =p.devl_project_id
and rpp.enclosing_folder = rpf.object_id
AND rpp.object_type     ='PRJ'
AND R.DISABLED_FLAG=0  --update only enabled rules
AND rpf.object_type = 'FLD'
--AND P.DEVL_PROJECT_ID=1037298 --add this if you want to update specific model only
AND class_name LIKE 'xxcz.cx.MyOldClass'
AND RPF.NAME LIKE 'Models – In Process'
AND r.rule_id=ru.rule_id
);