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

  CREATE OR REPLACE EDITIONABLE PROCEDURE "ENVX_OPER"."CHANGE_QUEUE_ORDER" (
	pi_queue_alias IN VARCHAR2,
	pi_id_request  IN NUMBER,
	po_result      OUT NUMBER
) AS
	j       NUMBER := 0;
	v_order NUMBER := 0;
BEGIN

	FOR i IN (
		SELECT *
		  FROM deployment_request_queue
		 WHERE queue_alias = pi_queue_alias
		   AND id_request != pi_id_request
		   AND status_queue = 0
	  ORDER BY queue_order
	) LOOP

		j := j + 1;

		UPDATE deployment_request_queue
		   SET queue_order = j 
		 WHERE queue_alias = i.queue_alias
		   AND id_request = i.id_request;

	END LOOP;

	COMMIT;

END;


/
