You are on page 1of 2

[ M1S3 - CODE REFERENCE ]

CCS0029 – DATABASE SYSTEM WITH ADMINISTRATION


---------------------------------------------------------------------------------------------------------------------------------------------------------

1.) Write a PL/SQL block to display the country_id and country_name values from the WF_COUNTRIES table
for country_id whose values range from 51 through 55.

Supply the missing elements of the given code to satisfy the above statement.

declare

vcid countries.country_id%type;

vcname countries.country_name%type;

vctr pls_integer;

begin

vctr := _____;

loop

select country_id, country_name into vcid, vcname

from countries where country_id = _______;

dbms_output.put_line(vcid||' '||vcname);

vctr := _________;

exit when vctr ____ 55;

end loop;

end;
2.) In the code below, three new location IDs for Montreal, Canada, are inserted in the LOCATIONS
table.
Supply the missing part of the code to satisfy the above statement.

DECLARE

v_loc_id locations.location_id%TYPE;

BEGIN

SELECT MAX(location_id) INTO _________ FROM locations

WHERE country_id = 2;

FOR i ____ 1..3 LOOP

INSERT INTO locations(location_id, city, country_id)

VALUES((v_loc_id + i), 'Montreal', 2);

END LOOP;

END;

You might also like