DROP FUNCTION if EXISTS	fn_get_lookup_value;
CREATE  FUNCTION fn_get_lookup_value(lookup_code VARCHAR(50), 
																	lookup_value_code VARCHAR(50))
RETURNS VARCHAR(100)
DETERMINISTIC
BEGIN

		DECLARE	l_value VARCHAR(100);

		Select 	lv.description 
		INTO	l_value
		from	lookups l,
				lookup_values lv
		where	l.id = lv.lookup_id
		AND		l.lookup_code = lookup_code
		AND		lv.short_code = lookup_value_code
		AND		l.is_active = 'Y'
		AND		lv.is_active = 'Y';

		RETURN (l_value);

END;