Delimiter //
/**
 * Set the default adresse check state value.
 * 
 * @param int batchnum
 * @author Benoit
 * @ticket #4005
 */ 
Drop Procedure if Exists LOADER_CONTACTS_NORMALIZE_MAP_ADDRESS_CHECK_STATE_SET//
 
Create Procedure LOADER_CONTACTS_NORMALIZE_MAP_ADDRESS_CHECK_STATE_SET (
    In batchnum int
)
Begin

    Update 
        LOADER_CONTACTS C
        Inner Join LOADER_STATUS S
            On S.ID_LOADER_STATUS = C.LOADER_STATUS_ID_LOADER_STATUS
    Set 
        C.DF_CHECK_STAT_ID_DF_CHECK_STAT = 1 -- DOCHECK
    Where
        S.LOADER_STATUS_BATCH_NUM = batchnum
        -- And C.ID_CONTACTS_NEW Is Not Null  -- Commented because both new and updated contacts need it
    ;

End //
Delimiter ;