Delimiter //
/**
    In batchnum Int : num du lot, si 0 ou null traitement de l'ensembles des lignes
*/

Drop Procedure if exists LOADER_ENTRIES_COPY//

Create Procedure LOADER_ENTRIES_COPY (
    In batchnum int
)
Begin
    updateQuerys: Begin
        call LOADER_ENTRIES_UPDATE(batchnum);

    end ;

    insertQuerys: Begin
        call CASH_AUTOINCREMENT_VALUE('ENTRIES', @lastid);

        call LOADER_ENTRIES_INSERT(batchnum, @lastid);
        call LOADER_ENTRIES_HAS_ACCOUNTS_INSERT(batchnum, @lastid);
        call LOADER_ENTRIES_INSERT_FORCED_MATCH_STATUS(batchnum, @lastid);
		
    end ;

End //

Delimiter ;