Delimiter //
/**
 * Set the default sand state value.
 * 
 * @param int batchnum
 * @author Benoit
 * ticket #4004
 */ 
Drop Procedure if Exists LOADER_ENTRIES_NORMALIZE_MAP_PAYMENT_SCHEDULE_STATUS_SET//
 
Create Procedure LOADER_ENTRIES_NORMALIZE_MAP_PAYMENT_SCHEDULE_STATUS_SET (
    In batchnum int
)
Begin

    Update 
        LOADER_ENTRIES E
        Inner Join LOADER_STATUS S
            On S.ID_LOADER_STATUS = E.LOADER_STATUS_ID_LOADER_STATUS
    Set 
        E.DF_PAY_SCHED_STATUS_ID_DF_PAY_SCHED_STATUS = 1 -- NOSCHEDULED
    Where
        S.LOADER_STATUS_BATCH_NUM = batchnum
        And E.ID_ENTRIES_NEW Is Not Null
    ;

End //
Delimiter ;