Delimiter //
Drop Procedure If Exists LOADER_REFDATA_NORMALIZE_CHECK_ENTRIES_ACC_EXT_REF_NOTNULL//
Create Procedure LOADER_REFDATA_NORMALIZE_CHECK_ENTRIES_ACC_EXT_REF_NOTNULL(
    In batchnum Int
)
Begin

	call LOADER_BUILD_REF_DATA_CHECK_BASE_QUERY (
				'ENTRIES_ACC_EXT_REF', batchnum, 'Entries ref could not be empty', '', 0, @query
			)
		;
	set @query = Concat(@query
					, ' And Coalesce(ENTRIES_ACC_EXT_REF, '''') = '''' '
					, ' And LOADER_REFDATA_TYPE In (''ENTRIES'', ''ACCRED_ENTRIES'')'
				)
			;

	PREPARE stmt FROM @query;
	execute stmt			
		;
	Deallocate prepare stmt;

End//
Delimiter ;