--------------------------------------------------------
--  DDL for Procedure MANAGE_REQ_OBJECT_ORDER
--------------------------------------------------------
set define off;

  CREATE OR REPLACE EDITIONABLE PROCEDURE "ENVX_OPER"."MANAGE_REQ_OBJECT_ORDER" (pi_id_dep_req_object IN NUMBER,
													 pi_id_req_hgroup IN VARCHAR2)
AS
v_aux NUMBER := 0;
BEGIN

    DELETE FROM DEPLOYMENT_REQ_OBJECT
    WHERE ID_DEP_REQ_OBJECT = pi_id_dep_req_object;
    commit; 

    FOR i in (select * 
              from deployment_req_object 
              where ID_REQ_HGROUP = pi_id_req_hgroup--:P300_ID
              ORDER BY OBJECT_ORDER
             ) 
    LOOP
        v_aux := v_aux + 1;
       update DEPLOYMENT_REQ_OBJECT
          set OBJECT_ORDER = v_aux
        where ID_DEP_REQ_OBJECT = i.ID_DEP_REQ_OBJECT;

    END LOOP;
END;


/
