1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
   |  
CREATE OR REPLACE VIEW sch2.vue_action AS 
 SELECT 
        CASE
            WHEN act.id_action IS NULL THEN 'D'::text
            ELSE 'I'::text
        END AS j_flag, journal.ets, journal.j_date, 
        CASE
            WHEN act.id_action IS NULL THEN ((('delete from sch1.action where id_action='::text || chr(39)) || journal.id_action::text) || chr(39)) || ';'::text
            ELSE NULL::text
        END AS j_delete, 
        CASE
            WHEN act.id_action IS NULL THEN NULL::text
            ELSE ((((((('insert into sch1.action values('::text || chr(39)) || journal.id_action::text) || chr(39)) || ','::text) || chr(39)) || act.libelle::text) || chr(39)) || ');'::text
        END AS j_insert, 
        CASE
            WHEN act.id_action IS NULL THEN NULL::text
            ELSE ((((((('update sch1.action set libelle='::text || chr(39)) || act.libelle::text) || chr(39)) || ' where id_action='::text) || chr(39)) || journal.id_action::text) || chr(39)) || ';'::text
        END AS j_update
   FROM ( SELECT jour_action.ets, jour_action.id_action, max(jour_action.j_date) AS j_date
           FROM sch2.j_action jour_action
          WHERE jour_action.j_consumed::text = '1'::text
          GROUP BY jour_action.ets, jour_action.id_action) journal
   LEFT JOIN action act ON journal.id_action::text = act.id_action::text; | 
Partager