dep:
  - v_listes_1
src: |
  SELECT v_listes_1.liste_id_combo AS oid,
      ''::text AS code,
      v_listes_1.texte,
      v_listes_1.liste_alias_combo AS alias,
      v_listes_1.lvl AS level,
      ('0'::text || v_listes_1.sort) || chr(1) AS tri,
          CASE
              WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1)
              ELSE '0'::character(1)
          END AS is_cti
     FROM activite.v_listes_1
    WHERE v_listes_1.table_code = 'GME'::text AND v_listes_1.lvl <> '0'::text
  UNION ALL
   SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid,
      ''::text AS code,
      t_classes.texte,
      ''::text AS alias,
      '1'::text AS level,
      '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri,
          CASE
              WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1)
              ELSE '0'::character(1)
          END AS is_cti
     FROM activite.t_classes,
      activite.t_listes_tables
    WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'GME'::text
  UNION ALL
   SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid,
      ''::text AS code,
      t_classes_sections.texte,
      ('#LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.code AS alias,
      '2'::text AS level,
      '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri,
          CASE
              WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1)
              ELSE '0'::character(1)
          END AS is_cti
     FROM activite.t_classes,
      activite.t_classes_sections,
      activite.t_listes_tables
    WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'GME'::text
  UNION ALL
   SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid,
      ''::text AS code,
      'Section non attribuée'::character varying AS texte,
      ''::text AS alias,
      '2'::text AS level,
      '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri,
          CASE
              WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1)
              ELSE '0'::character(1)
          END AS is_cti
     FROM activite.t_classes,
      activite.t_listes_tables
    WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'GME'::text
  UNION ALL
   SELECT 'CM'::text || t_gme_c.cm_id::text AS oid,
      t_gme_c.cm_code AS code,
      (t_gme_c.cm_code || ' '::text) || t_gme_c.cm_texte AS texte,
      ''::text AS alias,
      '1'::text AS level,
      '6'::text ||
          CASE
              WHEN t_gme_c.cm_id = 0 THEN '00'::text
              ELSE t_gme_c.cm_code
          END AS tri,
      '0'::character(1) AS is_cti
     FROM activite.t_gme_c
    WHERE t_gme_c.gme_id <> 0 AND (t_gme_c.gme_id IN ( SELECT p_oids.oid
             FROM activite.p_oids
            WHERE p_oids.code_table = 'gme'::text))
    GROUP BY ('CM'::text || t_gme_c.cm_id::text), t_gme_c.cm_code, ((t_gme_c.cm_code || ' '::text) || t_gme_c.cm_texte), ''::text, '1'::text, ('6'::text ||
          CASE
              WHEN t_gme_c.cm_id = 0 THEN '00'::text
              ELSE t_gme_c.cm_code
          END)
  UNION ALL
   SELECT 'GN'::text || t_gme_c.gn_id::text AS oid,
      t_gme_c.gn_code AS code,
      (t_gme_c.gn_code || ' '::text) || t_gme_c.gn_texte AS texte,
      ''::text AS alias,
      '2'::text AS level,
      '6'::text ||
          CASE
              WHEN t_gme_c.gn_id = 0 THEN '000'::text
              ELSE (t_gme_c.cm_code || chr(1)) || t_gme_c.gn_code
          END AS tri,
      '0'::character(1) AS is_cti
     FROM activite.t_gme_c
    WHERE t_gme_c.gme_id <> 0 AND (t_gme_c.gme_id IN ( SELECT p_oids.oid
             FROM activite.p_oids
            WHERE p_oids.code_table = 'gme'::text))
    GROUP BY ('GN'::text || t_gme_c.gn_id::text), t_gme_c.gn_code, ((t_gme_c.gn_code || ' '::text) || t_gme_c.gn_texte), ''::text, '2'::text, ('6'::text ||
          CASE
              WHEN t_gme_c.gn_id = 0 THEN '000'::text
              ELSE (t_gme_c.cm_code || chr(1)) || t_gme_c.gn_code
          END)
  UNION ALL
   SELECT 'RGME'::text || t_gme_c.rgme_id::text AS oid,
      t_gme_c.rgme_code AS code,
      (t_gme_c.rgme_code || ' '::text) || t_gme_c.rgme_texte AS texte,
      ''::text AS alias,
      '3'::text AS level,
      '6'::text ||
          CASE
              WHEN t_gme_c.rgme_id = 0 THEN '0000'::text
              ELSE (((t_gme_c.cm_code || chr(1)) || t_gme_c.gn_code) || chr(1)) || t_gme_c.rgme_code
          END AS tri,
      '0'::character(1) AS is_cti
     FROM activite.t_gme_c
    WHERE t_gme_c.gme_id <> 0 AND (t_gme_c.gme_id IN ( SELECT p_oids.oid
             FROM activite.p_oids
            WHERE p_oids.code_table = 'gme'::text))
    GROUP BY ('RGME'::text || t_gme_c.rgme_id::text), t_gme_c.rgme_code, ((t_gme_c.rgme_code || ' '::text) || t_gme_c.rgme_texte), ''::text, '3'::text, ('6'::text ||
          CASE
              WHEN t_gme_c.rgme_id = 0 THEN '0000'::text
              ELSE (((t_gme_c.cm_code || chr(1)) || t_gme_c.gn_code) || chr(1)) || t_gme_c.rgme_code
          END)
  UNION ALL
   SELECT 'GME'::text || t_gme_c.gme_id::text AS oid,
      t_gme_c.gme_code AS code,
      (t_gme_c.gme_code || ' '::text) || t_gme_c.gme_texte AS texte,
      ''::text AS alias,
      '4'::text AS level,
      '6'::text ||
          CASE
              WHEN t_gme_c.gme_id = 0 THEN '00000'::text
              ELSE (((((t_gme_c.cm_code || chr(1)) || t_gme_c.gn_code) || chr(1)) || t_gme_c.rgme_code) || chr(1)) || t_gme_c.gme_code
          END AS tri,
      '0'::character(1) AS is_cti
     FROM activite.t_gme_c
    WHERE t_gme_c.gme_id <> 0 AND (t_gme_c.gme_id IN ( SELECT p_oids.oid
             FROM activite.p_oids
            WHERE p_oids.code_table = 'gme'::text))
    GROUP BY ('GME'::text || t_gme_c.gme_id::text), t_gme_c.gme_code, ((t_gme_c.gme_code || ' '::text) || t_gme_c.gme_texte), ''::text, '4'::text, ('6'::text ||
          CASE
              WHEN t_gme_c.gme_id = 0 THEN '00000'::text
              ELSE (((((t_gme_c.cm_code || chr(1)) || t_gme_c.gn_code) || chr(1)) || t_gme_c.rgme_code) || chr(1)) || t_gme_c.gme_code
          END), ('0'::character(1))
    ORDER BY 6;