Commit b84a6250 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

SQL : Mise à jour de la fonction transfert_these().

parent c8dd52d9
Loading
Loading
Loading
Loading
+32 −0
Changes for doc/release-notes/v6.0.6.md: 32 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -205,4 +205,36 @@ create or replace view v_extract_theses as
         left join dernier_rapport_csi rcsi on rcsi.these_id = th.id
  where th.histo_destruction is null
;


create or replace function transfert_these(fromtheseid bigint, totheseid bigint) returns void
  language plpgsql
as
$$
BEGIN
  --     select 'update '||rpad(table_name, 35)||' set '||column_name||' = totheseid where '||column_name||' = fromtheseid ;' from information_schema.columns
--     where column_name ilike 'these_id' and
--       table_name not ilike 'v\_%' and
--       table_name not ilike 'src_%' and
--       table_name not ilike 'tmp_%' and
--       lower(table_name) not in ('acteur', 'financement', 'these_annee_univ', 'titre_acces', 'step_star_log');

  --update soutenance_proposition set histo_destruction = now(), histo_destructeur_id = 1 where these_id = totheseid ;

  update attestation                         set these_id = totheseid where these_id = fromtheseid ;
  update diffusion                           set these_id = totheseid where these_id = fromtheseid ;
  update fichier_these                       set these_id = totheseid where these_id = fromtheseid ;
  update metadonnee_these                    set these_id = totheseid where these_id = fromtheseid ;
  update rapport                             set these_id = totheseid where these_id = fromtheseid ;
  update rdv_bu                              set these_id = totheseid where these_id = fromtheseid ;
  update soutenance_intervention             set these_id = totheseid where these_id = fromtheseid ;
  update soutenance_proposition              set these_id = totheseid where these_id = fromtheseid ;
  update validation                          set these_id = totheseid where these_id = fromtheseid ;
  update csi_membre                          set these_id = totheseid where these_id = fromtheseid ;
  update rapport_activite                    set these_id = totheseid where these_id = fromtheseid ;

  refresh materialized view mv_recherche_these;
END;
$$;

```
 No newline at end of file