Delimiter //
/**
 * Author:  armen
 * Created: 20 juil. 2020
 */
Drop Procedure if exists LOADER_CREDITPROVIDERS_NORMALIZE_CHECK_ACCOUNT_PROVIDED //
Create Procedure LOADER_CREDITPROVIDERS_NORMALIZE_CHECK_ACCOUNT_PROVIDED (
    In batchnum int
)
Begin
    Set @lcnap_batchnum = batchnum;
    Update
        LOADER_STATUS sts
        Inner Join LOADER_CREDITPROVIDERS lcp
            On sts.ID_LOADER_STATUS = lcp.LOADER_STATUS_ID_LOADER_STATUS
    Set
        sts.LOADER_STATUS_ERRCOUNT = sts.LOADER_STATUS_ERRCOUNT + 1
        , sts.LOADER_STATUS_ERRMSGS =  LOADER_CONCAT_ERR(sts.LOADER_STATUS_ERRMSGS, 'Ni la référence de compte ni le siren/siret ne sont fournis')
    Where
        sts.LOADER_STATUS_BATCH_NUM = @lcnap_batchnum 
        And Trim(Coalesce(lcp.ACCOUNTS_REF, '')) = ''
        And Trim(Coalesce(lcp.CONTACTS_BUSINESS_SIRET, '')) = ''
    ;
End //
Delimiter ;
