CREATE OR REPLACE FUNCTION get_quote_items(p_quote_id IN NUMBER) RETURN VARCHAR2 IS ret_items VARCHAR2(250); first_item BOOLEAN := TRUE; BEGIN --blank string ret_items := ''; FOR cur_item IN (SELECT adit.description FROM quote_items quit JOIN additional_items adit ON (adit.code = quit.adit_code) WHERE quit.qute_id = p_quote_id AND quit.adit_code IS NOT NULL ORDER BY description) LOOP IF first_item THEN ret_items := cur_item.description; first_item := FALSE; ELSE --add a seperator ret_items := ret_items || ', ' || cur_item.description; END IF; END LOOP; RETURN(ret_items); EXCEPTION WHEN OTHERS THEN --return an empty string just in case RETURN(NULL); END get_quote_items; /