Commit 88ff3bc7 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

SQL Doctorants Apogée/Physalis : ajout de la colonne code_apprenant_in_source (numero étudiant).

SQL Origines de financement Apogée : données désormais puisées dans la table 'origine_financement' et plus en dur.
parent 9ac18da3
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@
--

--
-- NB : Seule la vue `V_SYGAL_DOCTORANT_V3` existe en version "V3", c'est normal.
-- NB : Seule les vues `V_SYGAL_DOCTORANT_V3` et `V_SYGAL_ORIGINE_FINANCEMENT_V3` existent en version V3, c'est normal.
--      Les autres vues/tables restent en version "V2".
--

@@ -650,6 +650,17 @@ from acteur act
         left join V_SYGAL_ROLE_JURY  rjc on rjc.cod_roj = act.cod_roj_compl
/

create or replace view V_SYGAL_ORIGINE_FINANCEMENT_V3 as
select COD_OFI as ID,
       COD_OFI as SOURCE_CODE,
       'apogee' as source_id,
       COD_OFI,
       LIC_OFI,
       LIB_OFI
from origine_financement
where TEM_EN_SVE_OFI = 'O'
/

create or replace view V_SYGAL_FINANCEMENT_V2 as
with inscription_admin as (
    select
+0 −42
Original line number Diff line number Diff line
@@ -27,45 +27,3 @@ create view V_SYGAL_ROLE_TR as
    )
    select * from tmp
/

--
-- Vues des seules origines de financement à prendre en compte (éventuellement renommées).
--
create or replace view V_SYGAL_ORIGINE_FINANCEMENT_V2 as
with tmp(source_id, COD_OFI, LIC_OFI, LIB_OFI) as (
    select 'apogee', '10', 'SALARIE',     'Etudiant salarié'                         from dual union all
    select 'apogee', '11', 'SANS FIN',    'Sans financement'                         from dual union all
    select 'apogee', '13', 'DOT EPSCP',   'Dotation des EPSCP'                       from dual union all
    select 'apogee', '14', 'DOT EPST',    'Dotation des EPST'                        from dual union all
    select 'apogee', '15', 'POLYTECH',    'Programmes Spé. Normaliens, Polytechnici' from dual union all
    select 'apogee', '16', 'HANDICAP',    'Programme Spécifique Handicap'            from dual union all
    select 'apogee', '17', 'DEFENSE',     'Ministère de la Défense (dont DGA)'       from dual union all
    select 'apogee', '18', 'AGRICULTUR',  'Ministère de l''Agriculture'              from dual union all
    select 'apogee', '19', 'AFF ETRANG',  'Ministère des Affaires Etrangères'        from dual union all
    select 'apogee', '20', 'SANTE',       'Ministère de la Santé'                    from dual union all
    select 'apogee', '21', 'AUTRES MIN',  'Autres Ministères'                        from dual union all
    select 'apogee', '22', 'DOT EPIC',    'Dotation des EPIC'                        from dual union all
    select 'apogee', '23', 'DOT EPA',     'Dotation des EPA'                         from dual union all
    select 'apogee', '24', 'NORMANDIE',   'Région Normandie'                         from dual union all
    select 'apogee', '25', 'AUT COLLEC',  'Autre Collectivité Territoriale'          from dual union all
    select 'apogee', '26', 'ANR',         'ANR'                                      from dual union all
    select 'apogee', '27', 'IDEX',        'IDEX'                                     from dual union all
    select 'apogee', '28', 'PIA',         'Autres dispositifs du PIA (dont LABEX)'   from dual union all
    select 'apogee', '29', 'AUT AFFPR',   'Autres Finan. Pub. d''Agences Françaises' from dual union all
    select 'apogee', '30', 'FI PUB PRV',  'Financements Mixtes Public Privé'         from dual union all
    select 'apogee', '31', 'CIFRE',       'Conventions CIFRE'                        from dual union all
    select 'apogee', '32', 'PART RECH',   'Partenariat de Recherche'                 from dual union all
    select 'apogee', '33', 'MECENAT',     'Mécénat y compris Fondations et Asso.'    from dual union all
    select 'apogee', '34', 'ERC',         'ERC'                                      from dual union all
    select 'apogee', '35', 'MARIE CURI',  'Actions Marie Sklodowska Curie'           from dual union all
    select 'apogee', '36', 'ERASMUS',     'ERASMUS'                                  from dual union all
    select 'apogee', '37', 'AUT PRO EU',  'Autre Programme Européen'                 from dual union all
    select 'apogee', '38', 'GOUV EUROP',  'Gouvernement Etranger Européen'           from dual union all
    select 'apogee', '39', 'GOUV NON E',  'Gouvernement Etranger Hors Europe'        from dual union all
    select 'apogee', '40', 'AUT FI ETR',  'Autres Financements Etrangers'            from dual union all
    select 'apogee', '41', 'ENT ETR',     'Entreprise Etrangère'                     from dual union all
    select 'apogee', '42', 'ORG FC',      'Financements Organismes FC'               from dual union all
    select 'apogee', '43', 'ORG INTER',   'Organismes Internationaux'                from dual
)
select COD_OFI as ID, COD_OFI as SOURCE_CODE, source_id, COD_OFI, LIC_OFI, LIB_OFI from tmp
/
+135 −4
Original line number Diff line number Diff line
@@ -3,10 +3,13 @@
----------------------------------------------------------

--
-- NB : Seules les vues/tables modifiées existent en version "V3" (ex: V_SYGAL_DOCTORANT_V3).
-- NB : Seule les vues `V_SYGAL_DOCTORANT_V3` et `V_SYGAL_ORIGINE_FINANCEMENT_V3` passent en version V3, c'est normal.
--      Les vues/tables inchangées restent en version "V2".
--

--
-- Doctorants : ajout de la colonne "code_apprenant_in_source" (numero étudiant).
--
create or replace view V_SYGAL_DOCTORANT_V3 as
    select distinct
        ind.cod_etu as source_code, -- Identifiant unique
@@ -14,7 +17,7 @@ create or replace view V_SYGAL_DOCTORANT_V3 as
        ind.cod_etu as id, -- Identifiant du doctorant
        ind.cod_etu as individu_id, -- Identifiant de l'individu
        ind.cod_nne_ind||ind.cod_cle_nne_ind as ine, -- INE du doctorant
        ind.cod_etu as code_apprenant_in_source -- Numero étudiant Apogée <<<<<<<<<<<<< nouvelle colonne
        ind.cod_etu as code_apprenant_in_source -- Numero étudiant <<<<<<<<<<<<< nouvelle colonne
    from these_hdr_sout ths
             join diplome        dip on dip.cod_dip     = ths.cod_dip
             join typ_diplome    tpd on tpd.cod_tpd_etb = dip.cod_tpd_etb
@@ -27,8 +30,136 @@ create or replace view V_SYGAL_DOCTORANT_V3 as
      and cod_etu is not null
;



--drop table SYGAL_DOCTORANT_V3;
create table SYGAL_DOCTORANT_V3 as select * from V_SYGAL_DOCTORANT_V3;
alter table SYGAL_DOCTORANT_V3 add source_insert_date date default sysdate;



--
-- Origines de financement : plus de valeurs en dur, la table "origine_financement" est sensée contenir les données correctes !
--
create or replace view V_SYGAL_ORIGINE_FINANCEMENT_V3 as
    select COD_OFI as ID,
           COD_OFI as SOURCE_CODE,
           'apogee' as source_id,
           COD_OFI,
           LIC_OFI,
           LIB_OFI
    from origine_financement
    where TEM_EN_SVE_OFI = 'O'
;

--drop table SYGAL_ORIGINE_FINANCEMENT_V3;
create table SYGAL_ORIGINE_FINANCEMENT_V3 as select * from V_SYGAL_ORIGINE_FINANCEMENT_V3;
alter table SYGAL_ORIGINE_FINANCEMENT_V3 add source_insert_date date default sysdate;



--
-- Thèses : ajout trim des sauts de ligne et tabulations sur le titre.
--
create or replace view V_SYGAL_THESE_V2 as
with inscription_administrative as (
    select distinct
        ths.cod_ind,
        iae.cod_dip,
        iae.cod_vrs_vdi
    from these_hdr_sout ths
             join ins_adm_etp    iae on iae.cod_ind = ths.cod_ind and ( iae.cod_dip, iae.cod_vrs_vdi ) in ( ( ths.cod_dip, ths.cod_vrs_vdi ), ( ths.cod_dip_anc, ths.cod_vrs_vdi_anc ) )
             join diplome        dip on dip.cod_dip = iae.cod_dip
             join typ_diplome    tpd on tpd.cod_tpd_etb = dip.cod_tpd_etb
    where ths.cod_ths_trv     =  '1'  -- Exclusion des travaux
      and iae.eta_iae         =  'E'  -- Inscription administrative non annulee
      and iae.eta_pmt_iae     =  'P'  -- Inscription administrative payee
      and dip.cod_tpd_etb     in ( '39', '40' )
      and tpd.eta_ths_hdr_drt =  'T'  -- Inscription en these
      and tpd.tem_sante       =  'N'  -- Exclusion des theses d exercice
),
     hierarchie_structures as (
         select
             cod_cmp_inf,
             cod_cmp_sup
         from cmp_cmp
         where connect_by_isleaf = 1
             connect by prior cod_cmp_sup = cod_cmp_inf
     ),
     ancienne_these as (
         select distinct
             cod_ind,
             cod_dip_anc,
             cod_vrs_vdi_anc,
             'A' eta_ths
         from these_hdr_sout
         where cod_ths_trv = '1'
           and cod_dip_anc is not null
     )

select
    ths.cod_ths as id,          -- Identifiant de la these
    ths.cod_ths as source_code, -- Identifiant unique
    'apogee' as source_id,  -- identifiant unique de la source

    ---------- Enregistrement de la these --------
    case when ths.eta_ths = 'S' and nvl ( ths.dat_sou_ths, sysdate + 1 ) > sysdate
             then 'E' else ths.eta_ths end eta_ths,     -- Etat de la these (E=En cours, A=Abandonnee, S=Soutenue, U=Transferee)
    ind.cod_etu as doctorant_id,                      -- Identifiant du doctorant
    ths.cod_dis,                                      -- Code discipline
    dis.lib_int1_dis,                                 -- Libellé discipline
    trim(CHR(09) from trim(CHR(13) from trim(CHR(10) from ths.lib_ths))) as lib_ths, -- Titre de la these
    ths.cod_lng,                                      -- Code langue etrangere du titre
    ths.dat_deb_ths,                                  -- Date de 1ere inscription
    ths.dat_abandon,                                  -- Date d'abandon
    ths.dat_transfert_dep,                            -- Date de transfert

    edo.cod_nat_edo as ecole_doct_id,                 -- Identifiant de l'ecole doctorale
    ths.cod_eqr as unite_rech_id,                     -- Identifiant de l'unité de recherche principale

    ----------- Cotutelle ----------
    pay.lib_pay,                                      -- Denomination pays de cotutelle
    nvl ( etb.lib_web_etb, etb.lib_etb ) lib_etb_cot, -- Denomination etablissement de cotutelle
    ths.tem_avenant,                                  -- Avenant a la convention de cotutelle (O/N)

    ------- Organisation de la soutenance ------
    ths.dat_prev_sou,                                 -- Date previsionnelle de soutenance
    ths.tem_sou_aut_ths,                              -- Soutenance autorisee (O/N/null)
    ths.dat_aut_sou_ths,                              -- Date d autorisation de soutenance
    ths.dat_sou_ths,                                  -- Date de soutenance de la these

    ---------- Confidentialite --------
    ths.dat_fin_cfd_ths,                              -- Date de fin de confidentialite de la these

    ---------- Jury et resultats --------
    tre.cod_neg_tre,                                  -- Resultat positif (1) ou non (0)
    ths.eta_rpd_ths,                                  -- Reproduction de la these ( O=Oui / C=Oui avec corrections / N=Non )
    decode(ths.eta_rpd_ths,
           'N', 'obligatoire',
           'C', 'facultative',
           null) as correction_possible,              -- Témoin de corrections attendues
    ths.tem_cor_ths as correction_effectuee           -- Témoin de corrections effectuees

from inscription_administrative iae
         join individu                   ind on ind.cod_ind = iae.cod_ind
         join version_diplome            vdi on vdi.cod_dip = iae.cod_dip and vdi.cod_vrs_vdi = iae.cod_vrs_vdi
         join these_hdr_sout             ths on ths.cod_ind = iae.cod_ind and ths.cod_dip = iae.cod_dip and ths.cod_vrs_vdi = iae.cod_vrs_vdi
         left join ancienne_these        anc on anc.cod_ind = ths.cod_ind and anc.cod_dip_anc = ths.cod_dip and anc.cod_vrs_vdi_anc = ths.cod_vrs_vdi and anc.eta_ths = ths.eta_ths
         left join annee_uni             ans on ans.cod_anu = ths.daa_fin_ths
         left join ecole_doctorale       edo on edo.cod_edo = ths.cod_edo
         left join secteur_rch           ser on ser.cod_ser = ths.cod_ser
         left join equipe_rch            eqr on eqr.cod_eqr = ths.cod_eqr
         left join resultat_vdi          rvi on rvi.cod_ind = iae.cod_ind and rvi.cod_dip = iae.cod_dip and rvi.cod_vrs_vdi = iae.cod_vrs_vdi and rvi.cod_ses = '0' and rvi.cod_adm = '1' and rvi.cod_tre is not null
         left join annee_uni             anr on anr.cod_anu = rvi.cod_anu
         left join typ_resultat          tre on tre.cod_tre = rvi.cod_tre
         left join mention               men on men.cod_men = rvi.cod_men
         left join hierarchie_structures ccm on ccm.cod_cmp_inf = ths.cod_cmp
         left join composante            cmp on cmp.cod_cmp = nvl ( ccm.cod_cmp_sup, ths.cod_cmp )
         left join diplome_sise          dis on dis.cod_dis = ths.cod_dis
         left join etablissement         etb on etb.cod_etb = ths.cod_etb
         left join pays                  pay on pay.cod_pay = ths.cod_pay
         left join etablissement         sou on sou.cod_etb = ths.cod_etb_sou
         left join etablissement         ori on ori.cod_etb = ths.cod_etb_origine
         left join langue                lng on lng.cod_lng = ths.cod_lng
where
    ths.cod_ths_trv = '1' and --  Exclusion des travaux
    anc.cod_dip_anc is null
;
+223 −2
Original line number Diff line number Diff line
@@ -7,6 +7,9 @@
--      Les vues/tables inchangées restent en version "V2".
--

--
-- Doctorants : ajout de la colonne "code_apprenant_in_source" (numero étudiant).
--
CREATE or replace VIEW "API_SCOLARITE"."V_SYGAL_DOCTORANT_V3" ("ID", "SOURCE_CODE", "SOURCE_ID", "INDIVIDU_ID", "INE", "CODE_APPRENANT_IN_SOURCE") AS
select
    i.pers_id  as ID ,
@@ -18,8 +21,226 @@ select
from RECHERCHE.DOCTORANT d left outer join grhum.INDIVIDU_ULR i on d.no_individu= i.no_individu
                           left outer join grhum.etudiant e on d.ETUD_NUMERO =  e.ETUD_NUMERO;



--drop table "API_SCOLARITE".SYGAL_DOCTORANT_V3;
create table "API_SCOLARITE".SYGAL_DOCTORANT_V3 as select * from "API_SCOLARITE".V_SYGAL_DOCTORANT_V3;
alter table "API_SCOLARITE".SYGAL_DOCTORANT_V3 add source_insert_date date default sysdate;




create or replace view "API_SCOLARITE"."V_SYGAL_ORIGINE_FINANCEMENT_V3" as
select *
from "API_SCOLARITE"."V_SYGAL_ORIGINE_FINANCEMENT_V2"
;

--drop table SYGAL_ORIGINE_FINANCEMENT_V3;
create table SYGAL_ORIGINE_FINANCEMENT_V3 as select * from "API_SCOLARITE"."V_SYGAL_ORIGINE_FINANCEMENT_V3";
alter table SYGAL_ORIGINE_FINANCEMENT_V3 add source_insert_date date default sysdate;



--
-- Thèses : ajout trim des sauts de ligne et tabulations sur le titre.
--
CREATE VIEW "API_SCOLARITE"."V_SYGAL_THESE_V2" ("ID", "SOURCE_CODE", "SOURCE_ID", "DOCTORANT_ID", "COD_DIS", "DAT_DEB_THS", "DAT_FIN_CFD_THS", "DAT_PREV_SOU", "DAT_SOU_THS", "ETA_THS", "LIB_INT1_DIS", "LIB_THS", "UNITE_RECH_ID", "ECOLE_DOCT_ID", "COD_NEG_TRE", "CORRECTION_POSSIBLE", "DAT_AUT_SOU_THS", "LIB_ETB_COT", "LIB_PAY", "TEM_AVENANT", "TEM_SOU_AUT_THS", "COD_LNG", "ETA_RPD_THS", "COD_ANU_PRM_IAE", "DAT_TRANSFERT_DEP", "DAT_ABANDON", "CORRECTION_EFFECTUEE") AS
select ID,
       ID as SOURCE_CODE,
       --     code_apprenant,
       --   annee_universitaire,
       SOURCE_ID,
       DOCTORANT_ID,
       COD_DIS,
       DAT_DEB_THS,
       DAT_FIN_CFD_THS ,
       DAT_PREV_SOU,
       DAT_SOU_THS,
       ETA_THS,
       LIB_INT1_DIS,
       LIB_THS ,
       unite_rech_id,
       ecole_doct_id,
       COD_NEG_TRE,
       CORRECTION_POSSIBLE,
       DAT_AUT_SOU_THS,
       LIB_ETB_COT,
       LIB_PAY,
       TEM_AVENANT,
       TEM_SOU_AUT_THS,
       COD_LNG,
       ETA_RPD_THS,
       extract (YEAR from DAT_DEB_THS) as COD_ANU_PRM_IAE,
       DAT_TRANSFERT_DEP,
       DAT_ABANDON,
       null as CORRECTION_EFFECTUEE

FROM
    ( select th.ID_THESE as ID,
             case
                 when d.etud_numero >=20000 then  lpad (d.etud_numero,9,0)--code pegase
                 else  to_char(d.etud_numero)

                 end as  code_apprenant,
             --  to_char(  h.etud_numero )as code_apprenant,
             h.hist_annee_scol  as annee_universitaire ,
             'physalis' as SOURCE_ID,
             case
                 when d.etud_numero >=20000 then  lpad (d.etud_numero,9,0)--code pegase
                 else  to_char(d.etud_numero)

                 end as  DOCTORANT_ID,

             --  to_char( h.etud_numero)  as DOCTORANT_ID,
             sise.code as COD_DIS,
             av.avt_date_deb as DAT_DEB_THS,
             '' as DAT_FIN_CFD_THS ,
             th.DATE_PREV_SOUTENANCE as DAT_PREV_SOU,
             th.DATE_SOUTENANCE DAT_SOU_THS,
             case
                 when  th.DATE_SOUTENANCE  <= sysdate then 'S'
                 when DATE_FIN_ANTICIPEE  is not null THEN 'A'
                 else 'E'

                 end as ETA_THS,
             --      case A_COT.ASS_CODE
             --      when 'D_LAB_THESE' THEN c_structure
             --    end as
             sise.libelle as LIB_INT1_DIS,

             trim(CHR(09) from trim(CHR(13) from trim(CHR(10) from con.CON_OBJET))) as LIB_THS ,
             etab_cot2.c_structure AS unite_rech_id,
             etab_cot1.c_structure AS ecole_doct_id,
             '' AS COD_NEG_TRE,
             null AS CORRECTION_POSSIBLE,
             th.DATE_PREV_SOUTENANCE AS DAT_AUT_SOU_THS,
             cot.NOM_ETABLISSEMENT_COTUTELLE as LIB_ETB_COT,
             cot.PAYS_COTUTELLE AS LIB_PAY,
             '' AS TEM_AVENANT,
             '' as TEM_SOU_AUT_THS,
             '' as COD_LNG,
             null AS ETA_RPD_THS,
             row_number() over(partition by th.ID_THESE order by h.hist_annee_scol desc) as rn,
             null as COD_ANU_PRM_IAE,
             th.DATE_TRANSFERT as DAT_TRANSFERT_DEP,
             th.DATE_FIN_ANTICIPEE as  DAT_ABANDON

      from RECHERCHE.DOCTORANT_THESE th left outer join  GRHUM.SISE_DOCTORAT_ETAB gd on th.ID_SISE_DOCTORAT_ETAB=gd.ID_SISE_DOCTORAT_ETAB
                                        left outer join grhum.sise_diplome sise on gd.id_sise_diplome = sise.id_sise_diplome
                                        left outer join recherche.doctorant d on d.id_doctorant = th.id_doctorant
                                        left outer join grhum.individu_ulr i on i.no_individu = d.no_individu
                                        left outer join accords.avenant av on av.con_ordre = th.con_ordre
                                        left outer join garnuche.historique h on h.etud_numero  = d.etud_numero
                                        left outer join garnuche.insc_dipl ins on ins.hist_numero = h.hist_numero and ins.res_code <> 'Z'
                                        left outer join accords.contrat  con on th.CON_ORDRE = con.con_ordre
                                        left outer join api_scolarite.v_sygal_co_tutelle cot on cot.id_doctorant = d.id_doctorant
                                        LEFT OUTER JOIN GRHUM.REPART_ASSOCIATION RA1 ON RA1.C_STRUCTURE = Con.CON_GROUPE_PARTENAIRE
                                        LEFT OUTER JOIN GRHUM.ASSOCIATION A_COT1 ON A_COT1.ASS_ID = RA1.ASS_ID
                                        LEFT OUTER JOIN grhum.structure_ulr etab_cot1 on etab_cot1.pers_id = ra1.pers_id
                                        LEFT OUTER JOIN ACCORDS.contrat_partenaire cp1 on cp1.con_ordre = con.con_ordre and cp1.pers_id = ra1.pers_id
                                        LEFT OUTER JOIN GRHUM.REPART_ASSOCIATION RA2 ON RA2.C_STRUCTURE = Con.CON_GROUPE_PARTENAIRE
                                        LEFT OUTER JOIN GRHUM.ASSOCIATION A_COT2 ON A_COT2.ASS_ID = RA2.ASS_ID
                                        LEFT OUTER JOIN grhum.structure_ulr etab_cot2 on etab_cot2.pers_id = ra2.pers_id
                                        LEFT OUTER JOIN ACCORDS.contrat_partenaire cp2 on cp2.con_ordre = con.con_ordre and cp2.pers_id = ra2.pers_id

      WHERE  A_COT1.ASS_CODE = 'D_ED_R' AND A_COT2.ASS_CODE = 'D_LAB_THESE' and  h.hist_annee_scol <= 2021))
where rn = 1
union
select ID,
       ID as SOURCE_CODE,
       -- code_apprenant,
--annee_universitaire,
       SOURCE_ID,
       DOCTORANT_ID,
       COD_DIS,
       DAT_DEB_THS,
       DAT_FIN_CFD_THS ,
       DAT_PREV_SOU,
       DAT_SOU_THS,
       ETA_THS,
       LIB_INT1_DIS,
       LIB_THS ,
       unite_rech_id,
       ecole_doct_id,
       COD_NEG_TRE,
       CORRECTION_POSSIBLE,
       DAT_AUT_SOU_THS,
       LIB_ETB_COT,
       LIB_PAY,
       TEM_AVENANT,
       TEM_SOU_AUT_THS,
       COD_LNG,
       ETA_RPD_THS,
       extract (YEAR from DAT_DEB_THS) as COD_ANU_PRM_IAE,
       DAT_TRANSFERT_DEP,
       DAT_ABANDON,
       null as CORRECTION_EFFECTUEE
FROM
    ( select
          th.ID_THESE as ID,
          case
              when d.etud_numero >=20000 then  lpad (d.etud_numero,9,0)--code pegase
              else  to_char(d.etud_numero)

              end as  code_apprenant,
          to_number(   h.annee_universitaire) as annee_universitaire,
          'physalis' as SOURCE_ID,
          case
              when d.etud_numero >=20000 then  lpad (d.etud_numero,9,0)--code pegase
              else  to_char(d.etud_numero)

              end as  DOCTORANT_ID,
          --   h.code_apprenant as DOCTORANT_ID,
          sise.code as COD_DIS,

          av.avt_date_deb as DAT_DEB_THS,
          '' as DAT_FIN_CFD_THS ,
          th.DATE_PREV_SOUTENANCE as DAT_PREV_SOU,
          th.DATE_SOUTENANCE DAT_SOU_THS,
          case
              when  th.DATE_SOUTENANCE  <= sysdate then 'S'
              when DATE_FIN_ANTICIPEE  is not null THEN 'A'
              else 'E'

              end as ETA_THS,
          --      case A_COT.ASS_CODE
          --      when 'D_LAB_THESE' THEN c_structure
          --    end as
          sise.libelle as LIB_INT1_DIS,
          trim(CHR(09) from trim(CHR(13) from trim(CHR(10) from con.CON_OBJET))) as LIB_THS ,
          etab_cot2.c_structure AS unite_rech_id,
          etab_cot1.c_structure AS ecole_doct_id,
          '' AS COD_NEG_TRE,
          null AS CORRECTION_POSSIBLE,
          th.DATE_PREV_SOUTENANCE AS DAT_AUT_SOU_THS,
          cot.NOM_ETABLISSEMENT_COTUTELLE as LIB_ETB_COT,
          cot.PAYS_COTUTELLE AS LIB_PAY,
          '' AS TEM_AVENANT,
          '' as TEM_SOU_AUT_THS,
          '' as COD_LNG,
          null AS ETA_RPD_THS,
          row_number() over(partition by th.ID_THESE order by h.annee_universitaire desc) as rn,
          null as COD_ANU_PRM_IAE,
          th.DATE_TRANSFERT as DAT_TRANSFERT_DEP,
          th.DATE_FIN_ANTICIPEE as  DAT_ABANDON

      from RECHERCHE.DOCTORANT_THESE th left outer join  GRHUM.SISE_DOCTORAT_ETAB gd on th.ID_SISE_DOCTORAT_ETAB=gd.ID_SISE_DOCTORAT_ETAB
                                        left outer join grhum.sise_diplome sise on gd.id_sise_diplome = sise.id_sise_diplome
                                        left outer join recherche.doctorant d on d.id_doctorant = th.id_doctorant
                                        left outer join grhum.individu_ulr i on i.no_individu = d.no_individu
                                        left outer join accords.avenant av on av.con_ordre = th.con_ordre
                                        left outer join pegase_synchro.ins_flux_inscription h on h.code_apprenant= d.etud_numero
          --     left outer join garnuche.historique h on h.etud_numero  = d.etud_numero
          --    left outer join garnuche.insc_dipl ins on ins.hist_numero = h.hist_numero and ins.res_code <> 'Z'
                                        left outer join accords.contrat  con on th.CON_ORDRE = con.con_ordre
                                        left outer join api_scolarite.v_sygal_co_tutelle cot on cot.id_doctorant = d.id_doctorant
                                        LEFT OUTER JOIN GRHUM.REPART_ASSOCIATION RA1 ON RA1.C_STRUCTURE = Con.CON_GROUPE_PARTENAIRE
                                        LEFT OUTER JOIN GRHUM.ASSOCIATION A_COT1 ON A_COT1.ASS_ID = RA1.ASS_ID
                                        LEFT OUTER JOIN grhum.structure_ulr etab_cot1 on etab_cot1.pers_id = ra1.pers_id
                                        LEFT OUTER JOIN ACCORDS.contrat_partenaire cp1 on cp1.con_ordre = con.con_ordre and cp1.pers_id = ra1.pers_id
                                        LEFT OUTER JOIN GRHUM.REPART_ASSOCIATION RA2 ON RA2.C_STRUCTURE = Con.CON_GROUPE_PARTENAIRE
                                        LEFT OUTER JOIN GRHUM.ASSOCIATION A_COT2 ON A_COT2.ASS_ID = RA2.ASS_ID
                                        LEFT OUTER JOIN grhum.structure_ulr etab_cot2 on etab_cot2.pers_id = ra2.pers_id
                                        LEFT OUTER JOIN ACCORDS.contrat_partenaire cp2 on cp2.con_ordre = con.con_ordre and cp2.pers_id = ra2.pers_id

      WHERE  A_COT1.ASS_CODE = 'D_ED_R' AND A_COT2.ASS_CODE = 'D_LAB_THESE'
        and h.code_apprenant is not null)
where rn = 1;
+1 −2
Original line number Diff line number Diff line
@@ -2,8 +2,7 @@
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
    <!-- (!) ATTENTION, notez que l'on pointe sur la table de la V2 (!) -->
    <entity name="ImportData\V3\Entity\Db\OrigineFinancement" table="SYGAL_ORIGINE_FINANCEMENT_V2">
    <entity name="ImportData\V3\Entity\Db\OrigineFinancement" table="SYGAL_ORIGINE_FINANCEMENT_V3">
        <id name="id" length="8" column="ID"/>
        <field name="sourceCode" length="6" column="SOURCE_CODE"/>
        <field name="sourceId" column="SOURCE_ID" length="64"/>