src: |
  SELECT t_ghmgme_c.ghmgme_id,
      t_ghmgme_c.ghmgme_code,
      t_ghmgme_c.ghmgme_texte,
          CASE
              WHEN t_ghmgme_c.cmd_id IS NULL AND t_ghmgme_c.cm_id IS NOT NULL THEN t_ghmgme_c.cm_id
              WHEN t_ghmgme_c.cmd_id IS NOT NULL AND t_ghmgme_c.cm_id IS NULL THEN t_ghmgme_c.cmd_id
              WHEN t_ghmgme_c.ghmgme_id < 0 THEN (-9990)::bigint
              ELSE 0::bigint
          END AS cmdcm_id,
          CASE
              WHEN t_ghmgme_c.cmd_id IS NULL AND t_ghmgme_c.cm_id IS NOT NULL THEN t_ghmgme_c.cm_code
              WHEN t_ghmgme_c.cmd_id IS NOT NULL AND t_ghmgme_c.cm_id IS NULL THEN t_ghmgme_c.cmd_code
              WHEN t_ghmgme_c.ghmgme_id < 0 THEN '99'::text
              ELSE t_ghmgme_c.ghmgme_code
          END AS cmdcm_code,
          CASE
              WHEN t_ghmgme_c.cmd_id IS NULL AND t_ghmgme_c.cm_id IS NOT NULL THEN t_ghmgme_c.cm_texte
              WHEN t_ghmgme_c.cmd_id IS NOT NULL AND t_ghmgme_c.cm_id IS NULL THEN t_ghmgme_c.cmd_texte
              WHEN t_ghmgme_c.ghmgme_id < 0 THEN 'Hors GHM-GME'::text
              ELSE t_ghmgme_c.ghmgme_texte
          END AS cmdcm_texte,
          CASE
              WHEN t_ghmgme_c.ghm5_id IS NULL AND t_ghmgme_c.rgme_id IS NOT NULL THEN t_ghmgme_c.rgme_id
              WHEN t_ghmgme_c.ghm5_id IS NOT NULL AND t_ghmgme_c.rgme_id IS NULL THEN t_ghmgme_c.ghm5_id
              WHEN t_ghmgme_c.ghmgme_id < 0 THEN (-9990)::bigint
              ELSE 0::bigint
          END AS ghm5rgme_id,
          CASE
              WHEN t_ghmgme_c.ghm5_id IS NULL AND t_ghmgme_c.rgme_id IS NOT NULL THEN t_ghmgme_c.rgme_code
              WHEN t_ghmgme_c.ghm5_id IS NOT NULL AND t_ghmgme_c.rgme_id IS NULL THEN t_ghmgme_c.ghm5_code
              WHEN t_ghmgme_c.ghmgme_id < 0 THEN t_ghmgme_c.ghmgme_code
              ELSE t_ghmgme_c.ghmgme_code
          END AS ghm5rgme_code,
          CASE
              WHEN t_ghmgme_c.ghm5_id IS NULL AND t_ghmgme_c.rgme_id IS NOT NULL THEN t_ghmgme_c.rgme_texte
              WHEN t_ghmgme_c.ghm5_id IS NOT NULL AND t_ghmgme_c.rgme_id IS NULL THEN t_ghmgme_c.ghm5_texte
              WHEN t_ghmgme_c.ghmgme_id < 0 THEN t_ghmgme_c.ghmgme_texte
              ELSE t_ghmgme_c.ghmgme_texte
          END AS ghm5rgme_texte,
      t_ghmgme_c.ghmgme_section_id,
      t_ghmgme_c.ghmgme_section_code,
      t_ghmgme_c.ghmgme_section_texte
     FROM activite.t_ghmgme_c
    ORDER BY t_ghmgme_c.ghmgme_id;