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

Create Procedure LOADER_ACCOUNTS_NORMALIZE_ACCOUNT_REF_IS_UNIQUE (
    In batchnum int
)
Begin
    Set @flagCountField='LOADER_ACCOUNTS_ERRCOUNT';
    Set @flagMsgField='LOADER_ACCOUNTS_ERRMSGS';
    Set @lastStatusField=null;
    Set @lastStatus=null;

    call LOADER_CHECK_UNIQUE (
	'LOADER_ACCOUNTS'
	, 'ACCOUNTS_REF'
	, null
	, 'LOADER_ACCOUNTS_BATCH_NUM'
	, batchnum
	, @flagCountField
        , @flagMsgField
        , @lastStatusField
        , @lastStatus
    );

End //

Delimiter ;