Delimiter //
/**
 * Author:  armen
 * Created: 1 déc. 2016
 */
drop function if exists CASH_BUSINESS_GET_ID_ACCOUNTS //

Create Function CASH_BUSINESS_GET_ID_ACCOUNTS(
		accounts_ref varchar(40)
		, id_entities Int unsigned
	)
	returns Int unsigned
Begin
	return (
			Select 
				ACC.ID_ACCOUNTS
			From ACCOUNTS ACC
			Where
				ACC.ACCOUNTS_REF = accounts_ref
				And ACC.ENTITIES_ID_ENTITIES =id_entities
			Limit 1
		)
	;
End //
Delimiter ;