Delimiter //
/**
 * 
 * @author armen
 * @ticket #5601
 */ 
Drop Procedure If Exists LOADER_ENTRIES_NORMALIZE_MAP_STATUS_PROVIDED//
Create Procedure LOADER_ENTRIES_NORMALIZE_MAP_STATUS_PROVIDED(
    In batch_num Int
)
Begin
    Set @idAdminParam = GET_LOADER_INFO('ID_ADMIN_PARAMS', batch_num);

    Update
        LOADER_ENTRIES E
        Inner Join LOADER_STATUS S
            On E.LOADER_STATUS_ID_LOADER_STATUS = S.ID_LOADER_STATUS
        Inner Join DF_ENTRIES_STATUT DFES
            On E.ENTRIES_STATUS_CODE = DFES.DF_ENTRIES_STATUT_CODE
    Set
        E.DF_ENTR_STT_ID_DF_ENTR_STT = DFES.ID_DF_ENTRIES_STATUT
    Where
        S.LOADER_STATUS_BATCH_NUM = batch_num
        And DFES.ADMIN_PARAMS_ID_ADMIN_PARAMS = @idAdminParam
        And Coalesce(E.ENTRIES_STATUS_CODE, '') <> ''
    ;

    -- Cf. LOADER_ENTRIES_NORMALIZE_MAP_STATUS_NOTPROVIDED pour les statuts non reconnus

End//
Delimiter ;