--
-- Set character set the client will use to send SQL statements to the server
--

--
-- Set default database
--
USE appros;

DELIMITER $$

--
-- Create procedure `ps_SGE_v0_get_All_Requetes`
--
CREATE
DEFINER = 'user_odbc'@'%'
PROCEDURE ps_SGE_v0_get_All_Requetes ()
COMMENT 'liste de toutes les requetes PRMs auprès de SGE'
BEGIN
  SELECT
    prm.id,
    prm.idPRM,
    prm.Id_PRM_GRD,
    request.*
  FROM tbl_gpt_societe_site_prm prm

    INNER JOIN tbl_sge_request request
      ON prm.id = request.ID_DB_FK_PRM
  WHERE prm.REF_GRD = 'ENEDIS'
  AND prm.flag_desactif IS NULL
  AND request.Date_Request_SGE IS NULL
  AND prm.Autorise_requete_SGE = TRUE;
END
$$

DELIMITER ;