Delimiter //
/**
    In batchnum Int : num du lot
*/

Drop Procedure if exists LOADER_RECLAIMS_COPY//

Create Procedure LOADER_RECLAIMS_COPY (
    In batchnum int
)
Begin
    Set @idEntities = GET_LOADER_INFO('ID_ENTITIES', batchnum);
    
	-- actualisation
	call LOADER_RECLAIMS_DETAILS_UPDATE(batchnum);

    -- creation des nouvelle réclamation
    -- obtention de la valeur de l'autoincrment
    call CASH_AUTOINCREMENT_VALUE('RECLAIMS', @lastid);
    call LOADER_RECLAIMS_INSERT(batchnum, @lastid);
	
    call LOADER_RECLAIMS_DETAILS_INSERT(batchnum, @lastid);

    call LOADER_RECLAIMS_SUMMARIES_INSERT(batchnum, @lastid);

    
End //

Delimiter ;