Tuesday, December 18, 2012

CZ: Republish the latest publication for given Model

This will republish the latest publication for given model. You can have various criteria to decide last publication.    

DECLARE
  P_API_VERSION NUMBER;
  P_PUBLICATION_ID NUMBER;
  P_USER_ID NUMBER;
  P_RESP_ID NUMBER;
  P_APPL_ID NUMBER;
  P_START_DATE DATE;
  P_END_DATE DATE;
  X_RUN_ID NUMBER;
  X_STATUS NUMBER;
BEGIN
  P_API_VERSION := 1.0;
  --P_PUBLICATION_ID := 123456;
  P_USER_ID := 1895; --PANKAJ_MANDALIYA 
  P_RESP_ID := 22687;
  P_APPL_ID := 708;
  P_START_DATE := SYSDATE;
  P_END_DATE := SYSDATE + 100;
 
  SELECT publication_id
  into p_publication_id
  FROM
    (SELECT publication_id
    FROM cz_model_publications
    WHERE object_id  =1070280 -- MODEL A
    AND disabled_flag=0
    AND deleted_Flag =0
    ORDER BY last_update_date DESC
    )
  WHERE rownum=1;

  CZ_MODELOPERATIONS_PUB.REPUBLISH_MODEL(
    P_API_VERSION => P_API_VERSION,
    P_PUBLICATION_ID => P_PUBLICATION_ID,
    P_USER_ID => P_USER_ID,
    P_RESP_ID => P_RESP_ID,
    P_APPL_ID => P_APPL_ID,
    P_START_DATE => P_START_DATE,
    P_END_DATE => P_END_DATE,
    X_RUN_ID => X_RUN_ID,
    X_STATUS => X_STATUS
  );

  DBMS_OUTPUT.PUT_LINE('X_RUN_ID = ' || X_RUN_ID);
  DBMS_OUTPUT.PUT_LINE('X_STATUS = ' || X_STATUS);

END;

No comments:

Post a Comment