dep: - v_listes_1 src: | SELECT v_listes_1.liste_id_combo AS oid, v_listes_1.texte, ''::text AS code, 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 = 'CODEPOST'::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, t_classes.texte, ''::text AS code, '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 JOIN activite.t_listes_tables ON t_classes.table_id = t_listes_tables.oid WHERE t_listes_tables.code = 'CODEPOST'::text UNION ALL SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, t_classes_sections.texte, ''::text AS code, '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 JOIN activite.t_classes_sections ON t_classes_sections.classe_id = t_classes.oid JOIN activite.t_listes_tables ON t_classes.table_id = t_listes_tables.oid WHERE t_listes_tables.code = 'CODEPOST'::text UNION ALL SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, 'Section non attribuée'::character varying AS texte, ''::text AS code, '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 JOIN activite.t_listes_tables ON t_classes.table_id = t_listes_tables.oid WHERE t_listes_tables.code = 'CODEPOST'::text UNION ALL SELECT '-8'::text AS oid, 'Codes postaux'::character varying AS texte, 'A'::text AS code, '1'::text AS level, '7'::text AS tri, '0'::character(1) AS is_cti UNION ALL ( SELECT DISTINCT 'DP'::text || t_codes_postaux_c.departement_id::text AS oid, (t_codes_postaux_c.departement_code || ' '::text) || t_codes_postaux_c.departement_texte AS texte, t_codes_postaux_c.departement_code AS code, '2'::text AS level, '7'::text || substr(t_codes_postaux_c.departement_code || ' '::text, 1, 5) AS tri, '0'::character(1) AS is_cti FROM activite.t_codes_postaux_c WHERE (t_codes_postaux_c.oid IN ( SELECT p_oids.oid FROM activite.p_oids WHERE p_oids.code_table = 'c_postaux'::text)) ORDER BY 'DP'::text || t_codes_postaux_c.departement_id::text, (t_codes_postaux_c.departement_code || ' '::text) || t_codes_postaux_c.departement_texte, t_codes_postaux_c.departement_code, '2'::text, '7'::text || substr(t_codes_postaux_c.departement_code || ' '::text, 1, 5)) UNION ALL ( SELECT DISTINCT 'CP'::text || t_codes_postaux_c.oid::text AS oid, (t_codes_postaux_c.code || ' '::text) || t_codes_postaux_c.texte AS texte, t_codes_postaux_c.code, '3'::text AS level, (('7'::text || substr(t_codes_postaux_c.departement_code || ' '::text, 1, 5)) || 'P'::text) || t_codes_postaux_c.code AS tri, '0'::character(1) AS is_cti FROM activite.t_codes_postaux_c WHERE (t_codes_postaux_c.oid IN ( SELECT p_oids.oid FROM activite.p_oids WHERE p_oids.code_table = 'c_postaux'::text)) ORDER BY 'CP'::text || t_codes_postaux_c.oid::text, (t_codes_postaux_c.code || ' '::text) || t_codes_postaux_c.texte, t_codes_postaux_c.code, '3'::text, (('7'::text || substr(t_codes_postaux_c.departement_code || ' '::text, 1, 5)) || 'P'::text) || t_codes_postaux_c.code) UNION ALL SELECT '-8'::text AS oid, 'Codes géographiques PMSI'::character varying AS texte, 'A'::text AS code, '1'::text AS level, '8'::text AS tri, '0'::character(1) AS is_cti UNION ALL ( SELECT DISTINCT 'DG'::text || t_codes_postaux_c.departement_id::text AS oid, (t_codes_postaux_c.departement_code || ' '::text) || t_codes_postaux_c.departement_texte AS texte, t_codes_postaux_c.departement_code AS code, '2'::text AS level, '8'::text || substr(t_codes_postaux_c.departement_code || ' '::text, 1, 5) AS tri, '0'::character(1) AS is_cti FROM activite.t_codes_postaux_c WHERE (t_codes_postaux_c.oid IN ( SELECT p_oids.oid FROM activite.p_oids WHERE p_oids.code_table = 'c_postaux'::text)) ORDER BY 'DG'::text || t_codes_postaux_c.departement_id::text, (t_codes_postaux_c.departement_code || ' '::text) || t_codes_postaux_c.departement_texte, t_codes_postaux_c.departement_code, '2'::text, '8'::text || substr(t_codes_postaux_c.departement_code || ' '::text, 1, 5)) UNION ALL ( SELECT DISTINCT 'GP'::text || t_codes_postaux_c.code_geographique_pmsi_id::text AS oid, (t_codes_postaux_c.code_geographique_pmsi_code || ' '::text) || t_codes_postaux_c.code_geographique_pmsi_texte AS texte, t_codes_postaux_c.code_geographique_pmsi_code AS code, '3'::text AS level, (('8'::text || substr(t_codes_postaux_c.departement_code || ' '::text, 1, 5)) || 'P'::text) || t_codes_postaux_c.code_geographique_pmsi_code AS tri, '0'::character(1) AS is_cti FROM activite.t_codes_postaux_c WHERE (t_codes_postaux_c.oid IN ( SELECT p_oids.oid FROM activite.p_oids WHERE p_oids.code_table = 'c_postaux'::text)) ORDER BY 'GP'::text || t_codes_postaux_c.code_geographique_pmsi_id::text, (t_codes_postaux_c.code_geographique_pmsi_code || ' '::text) || t_codes_postaux_c.code_geographique_pmsi_texte, t_codes_postaux_c.code_geographique_pmsi_code, '3'::text, (('8'::text || substr(t_codes_postaux_c.departement_code || ' '::text, 1, 5)) || 'P'::text) || t_codes_postaux_c.code_geographique_pmsi_code) UNION ALL SELECT '-8'::text AS oid, 'Territoires de santé'::character varying AS texte, 'A'::text AS code, '1'::text AS level, '9'::text AS tri, '0'::character(1) AS is_cti UNION ALL ( SELECT DISTINCT 'TS'::text || t_codes_postaux_c.territoire_sante_id::text AS oid, CASE WHEN t_codes_postaux_c.territoire_sante_texte = ''::text THEN 'Non renseigné'::text ELSE t_codes_postaux_c.territoire_sante_texte END AS texte, CASE WHEN t_codes_postaux_c.territoire_sante_code = ''::text THEN chr(127) || '*******'::text ELSE t_codes_postaux_c.territoire_sante_code END AS code, '2'::text AS level, CASE WHEN t_codes_postaux_c.territoire_sante_texte = ''::text THEN '9 '::text || 'Non renseigné'::text ELSE '9'::text || t_codes_postaux_c.territoire_sante_texte END AS tri, '0'::character(1) AS is_cti FROM activite.t_codes_postaux_c WHERE (t_codes_postaux_c.oid IN ( SELECT p_oids.oid FROM activite.p_oids WHERE p_oids.code_table = 'c_postaux'::text)) GROUP BY 'TS'::text || t_codes_postaux_c.territoire_sante_id::text, CASE WHEN t_codes_postaux_c.territoire_sante_texte = ''::text THEN 'Non renseigné'::text ELSE t_codes_postaux_c.territoire_sante_texte END, CASE WHEN t_codes_postaux_c.territoire_sante_code = ''::text THEN chr(127) || '*******'::text ELSE t_codes_postaux_c.territoire_sante_code END, '2'::text, CASE WHEN t_codes_postaux_c.territoire_sante_texte = ''::text THEN '9 '::text || 'Non renseigné'::text ELSE '9'::text || t_codes_postaux_c.territoire_sante_texte END ORDER BY 'TS'::text || t_codes_postaux_c.territoire_sante_id::text, CASE WHEN t_codes_postaux_c.territoire_sante_texte = ''::text THEN 'Non renseigné'::text ELSE t_codes_postaux_c.territoire_sante_texte END, CASE WHEN t_codes_postaux_c.territoire_sante_code = ''::text THEN chr(127) || '*******'::text ELSE t_codes_postaux_c.territoire_sante_code END, '2'::text, CASE WHEN t_codes_postaux_c.territoire_sante_texte = ''::text THEN '9 '::text || 'Non renseigné'::text ELSE '9'::text || t_codes_postaux_c.territoire_sante_texte END) ORDER BY 5;