Delimiter //
/**
 * If country is not provided, use the Admin Param country by default
 * @deprecated semble ne plus être utilisé. 
 * la PS  LOADER_CONTACTS_NORMALIZE_MAP_COUNTRY_PROVIDED le fait également
 * @param int batchnum
 * @author Jean-François
 * @ticket #2124
 */ 
Drop Procedure if Exists LOADER_CONTACTS_NORMALIZE_MAP_COUNTRY_NOT_PROVIDED//
 
Create Procedure LOADER_CONTACTS_NORMALIZE_MAP_COUNTRY_NOT_PROVIDED (
    In batchnum int
)
Begin
 
    Declare idAdminParams int;
    Set idAdminParams = GET_LOADER_INFO('ID_ADMIN_PARAMS', batchnum);

    UPDATE
        LOADER_CONTACTS C
        INNER JOIN LOADER_STATUS S
            ON S.ID_LOADER_STATUS = C.LOADER_STATUS_ID_LOADER_STATUS
        INNER JOIN ADMIN_PARAMS A
            ON A.ID_ADMIN_PARAMS = idAdminParams
    SET
        C.DF_COUNTRY_ID_DF_COUNTRY = A.DF_COUNTRY_ID_DF_COUNTRY
    WHERE 
        S.LOADER_STATUS_BATCH_NUM = batchnum
        AND C.ID_CONTACTS_NEW IS NOT NULL
        AND Coalesce(C.DF_COUNTRY_LABEL, '') = ''
    ;
    
End //
Delimiter ;