Delimiter //
/**
 * Set the default managment level value.
 * 
 * @param int batchnum
 * @author Benoit
 * @ticket #3902
 */ 
Drop Procedure if Exists LOADER_ACCOUNTS_NORMALIZE_MAP_MANAGMENT_LEVEL_SET//
 
Create Procedure LOADER_ACCOUNTS_NORMALIZE_MAP_MANAGMENT_LEVEL_SET (
    In batchnum int
)
Begin

    Update 
        LOADER_ACCOUNTS A
        Inner Join LOADER_STATUS S
            On S.ID_LOADER_STATUS = A.LOADER_STATUS_ID_LOADER_STATUS
    Set 
        A.DF_MNGT_LVL_ID_DF_MNGT_LVL = 1 -- First level in the table...
    Where
        S.LOADER_STATUS_BATCH_NUM = batchnum
        And A.ID_ACCOUNTS_NEW Is Not Null
    ;

End //
Delimiter ;