FUNCTION unique_company (name_in IN VARCHAR2, id_in IN NUMBER) RETURN BOOLEAN IS CURSOR company_cur IS SELECT company_id FROM company WHERE company_name = name_in AND (company_id != id_in OR id_in IS NULL); company_rec company_cur%ROWTYPE; new_company_name BOOLEAN; BEGIN -- Open the cursor and attempt to fetch a matching company record. OPEN company_cur; FETCH company_cur INTO company_rec; /* || The %NOTFOUND tells us if the fetch returned a record. Save it || into the local Boolean variable so that the information is available || even after the cursor is closed. Then close the cursor and return the || local variable. */ new_company_name := company_cur%NOTFOUND; CLOSE company_cur; RETURN new_company_name; END;