A test your function twice from an anonymous block

This preview shows page 3 - 6 out of 6 pages.

A. Test your function twice from an anonymous block using input values (50, 2) and (25, 3).
B. Test your function a third time using input values (16, 0). What happens?
C. Modify the function code to trap the ZERO_DIVIDE exception. The exception handler should return a value of zero from the function if ZERO_DIVIDE is raised. D. Test your function again using input values (16,0) as before. Now what happens? 4. List four major differences between a procedure and a function. 5. Look at the following two subprograms. The first is a procedure; the second is a function. Answer the following questions. CREATE OR REPLACE PROCEDURE get_country_name_proc
4 Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. (p_country_id IN countries.country_id%TYPE, p_country_name OUT countries.country_name%TYPE) IS BEGIN SELECT country_name INTO p_country_name FROM countries WHERE country_id = p_country_id; END; CREATE OR REPLACE FUNCTION get_country_name_func (p_country_id IN countries.country_id%TYPE) RETURN VARCHAR2 IS v_country_name countries.country_name%TYPE; BEGIN SELECT country_name INTO v_country_name FROM countries WHERE country_id = p_country_id; RETURN v_country_name; END; A. For a given country id, will both of these subprograms return the same results? B. What is the advantage of creating this subprogram as a function rather than as a procedure? C. Which of the following procedure and function calls are valid and which are not? Explain why the invalid ones will fail.
5

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture