C correct the problem in the previous step by

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

C. Correct the problem in the previous step by modifying the anonymous block again to pass the first two parameters using positional notation and the last two using named notation. Test the block again.
5. In your own words, describe the purpose of the DEFAULT option for parameters and state the two syntax options for providing the default value in the procedure header.
6. Find the country_id of your own country by executing a suitable SELECT…FROM countries…. Then retrieve your find_area_pop procedure from question 2C. Modify the code to use your country_id as a default value for the country_id IN parameter. Save your code. Then retrieve your anonymous block from question 2D and modify it so that it does NOT pass the country_id to the procedure. Test the block and check that your country’s details are returned and displayed. If your modified anonymous block does not work, correct it so it will.
7 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. CREATE OR REPLACE PROCEDURE find_area_pop (p_country_id IN wf_countries.country_id%TYPE DEFAULT <your_country_id>, p_country_name OUT wf_countries.country_name%TYPE, p_population OUT wf_countries.population%TYPE, p_pop_density OUT NUMBER) IS v_area wf_countries.area%TYPE; BEGIN SELECT country_name, population, area INTO p_country_name, p_population, v_area FROM wf_countries WHERE country_id = p_country_id;p_pop_density := p_population / v_area; EXCEPTION WHEN NO_DATA_FOUND THENDBMS_OUTPUT.PUT_LINE('Country id: '|| p_country_id|| ' does not exist'); END; DECLARE v_country_id wf_countries.country_id%TYPE; v_country_name wf_countries.country_name%TYPE; v_population wf_countries.population%TYPE; v_pop_density NUMBER(8,2); BEGIN v_country_id := 2; -- not needed anymore find_area_pop(p_country_name => v_country_name ,p_population => v_population, p_pop_density => v_pop_density); DBMS_OUTPUT.PUT_LINE('Name: ' || v_country_name ||' Population: ' || v_population ||' Density: '|| v_pop_density ||' per square km'); END;

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture