|
|
src: |
|
|
|
SELECT 'CH1'::text || t_actes.chapitre_1_id::text AS oid,
|
|
|
t_actes.chapitre_1_code AS code,
|
|
|
(t_actes.chapitre_1_code || ' '::text) || t_actes.chapitre_1_texte AS texte,
|
|
|
1 AS lvl
|
|
|
FROM pmsi.t_actes
|
|
|
JOIN pmsi.p_oids ON p_oids.code_table::text = 'actes'::text AND p_oids.oid = t_actes.oid
|
|
|
WHERE t_actes.chapitre_1_id::text IS DISTINCT FROM NULL::text AND t_actes.chapitre_1_id > 0 AND t_actes.chapitre_1_id::text < 99::text
|
|
|
GROUP BY t_actes.chapitre_1_id, t_actes.chapitre_1_code, t_actes.chapitre_1_texte, 1::integer
|
|
|
UNION ALL
|
|
|
SELECT 'CH2'::text || t_actes.chapitre_2_id::text AS oid,
|
|
|
t_actes.chapitre_2_code AS code,
|
|
|
(t_actes.chapitre_2_code || ' '::text) || t_actes.chapitre_2_texte AS texte,
|
|
|
2 AS lvl
|
|
|
FROM pmsi.t_actes
|
|
|
JOIN pmsi.p_oids ON p_oids.code_table::text = 'actes'::text AND p_oids.oid = t_actes.oid
|
|
|
WHERE t_actes.chapitre_2_id::text IS DISTINCT FROM NULL::text AND t_actes.chapitre_2_id > 0 AND t_actes.chapitre_2_id::text < 9999::text
|
|
|
GROUP BY t_actes.chapitre_2_id, t_actes.chapitre_2_code, t_actes.chapitre_2_texte, 2::integer
|
|
|
UNION ALL
|
|
|
SELECT 'CH3'::text || t_actes.chapitre_3_id::text AS oid,
|
|
|
t_actes.chapitre_3_code AS code,
|
|
|
(t_actes.chapitre_3_code || ' '::text) || t_actes.chapitre_3_texte AS texte,
|
|
|
3 AS lvl
|
|
|
FROM pmsi.t_actes
|
|
|
JOIN pmsi.p_oids ON p_oids.code_table::text = 'actes'::text AND p_oids.oid = t_actes.oid
|
|
|
WHERE t_actes.chapitre_3_id::text IS DISTINCT FROM NULL::text AND t_actes.chapitre_3_id > 0 AND t_actes.chapitre_3_id::text < 999999::text
|
|
|
GROUP BY t_actes.chapitre_3_id, t_actes.chapitre_3_code, t_actes.chapitre_3_texte, 3::integer
|
|
|
UNION ALL
|
|
|
SELECT 'CH4'::text || t_actes.chapitre_4_id::text AS oid,
|
|
|
t_actes.chapitre_4_code AS code,
|
|
|
(t_actes.chapitre_4_code || ' '::text) || t_actes.chapitre_4_texte AS texte,
|
|
|
4 AS lvl
|
|
|
FROM pmsi.t_actes
|
|
|
JOIN pmsi.p_oids ON p_oids.code_table::text = 'actes'::text AND p_oids.oid = t_actes.oid
|
|
|
WHERE t_actes.chapitre_4_id::text IS DISTINCT FROM NULL::text AND t_actes.chapitre_4_id > 0 AND t_actes.chapitre_4_id::text < 99999999::text
|
|
|
GROUP BY t_actes.chapitre_4_id, t_actes.chapitre_4_code, t_actes.chapitre_4_texte, 4::integer
|
|
|
ORDER BY 2;
|