Delimiter //
/**
 * Checks that the account's ref is not null
 *
 * @param int batchnum
 * @return void
*/
Drop Procedure if exists LOADER_ENTRIES_NORMALIZE_REF_IS_UNIQUE_PER_ACCOUNTS//

Create Procedure LOADER_ENTRIES_NORMALIZE_REF_IS_UNIQUE_PER_ACCOUNTS (
    In batchnum int
)
Begin
    Set @flagCountField='LOADER_ENTRIES_ERRCOUNT';
    Set @flagMsgField='LOADER_ENTRIES_ERRMSGS';
    Set @lastStatusField=null;
    Set @lastStatus=null;

    call LOADER_CHECK_UNIQUE (
	'LOADER_ENTRIES'
	, 'ACCOUNTS_REF'
	, 'ENTRIES_ACC_EXT_REF'
	, 'LOADER_ENTRIES_BATCH_NUM'
	, batchnum
	, @flagCountField
        , @flagMsgField
        , @lastStatusField
        , @lastStatus
    );

End //

Delimiter ;
