FUNCTION get_pat_areanum(p_pat_id IN NUMBER) RETURN VARCHAR2 AS
p_name lu.text%TYPE;
BEGIN
SELECT l.text
INTO p_name
FROM patient p
,lu l
WHERE p.keyid = p_pat_id
AND l.keyid = p.areanum_lu_id;
RETURN p_name;
EXCEPTION
WHEN OTHERS THEN
RETURN '';
END get_pat_areanum;