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

Create Procedure LOADER_LINKEDACCOUNTS_NORMALIZE_ACCOUNT_REF_IS_UNIQUE (
    In batchnum int
)
Begin
    Set @flagCountField='LOADER_LINKEDACCOUNTS_ERRCOUNT';
    Set @flagMsgField='LOADER_LINKEDACCOUNTS_ERRMSGS';
    Set @lastStatusField=null;
    Set @lastStatus=null;

    call LOADER_CHECK_UNIQUE (
	'LOADER_LINKEDACCOUNTS'
	, 'ACCOUNTS_REF'
	, 'ACCOUNTS_REF_LINKED'
	, 'LOADER_LINKEDACCOUNTS_BATCH_NUM'
	, batchnum
	, @flagCountField
        , @flagMsgField
        , @lastStatusField
        , @lastStatus
    );

End //

Delimiter ;