Delimiter //
/**
    In batchnum Int : num du lot, si 0 ou null traitement de l'ensembles des lignes
*/
Drop Procedure if exists LOADER_MATCHINGCODES_INSERT//
Create Procedure LOADER_MATCHINGCODES_INSERT (
    In batchnum int, 
    In lastId Int
)
Begin
        Insert Into MATCHINGCODES (
            ID_MATCHINGCODES, MATCHINGCODES_CODE, MATCHINGCODES_DATE
        )
        Select 
            src.ID_LOADER_MATCHINGCODES_MATCHINGCODES + lastId, src.MATCHINGCODES_CODE, src.MATCHINGCODES_DATE
        From
            LOADER_MATCHINGCODES_MATCHINGCODES src
--             Inner Join  LOADER_STATUS lst  
--                 On src.LOADER_STATUS_ID_LOADER_STATUS = lst.ID_LOADER_STATUS
--         Where 1 = 1  
--             And lst.LOADER_STATUS_ERRCOUNT = 0  
--             And lst.LOADER_STATUS_BATCH_NUM =  batchnum
        ;

End //

Delimiter ;


