0% found this document useful (0 votes)
85 views2 pages

PL/SQL Code for Country and Location Queries

The document provides two code examples with missing elements. The first displays country names from a table where the country ID ranges from 51 to 55 using a loop. The second inserts three new location IDs in Montreal, Canada by getting the maximum current ID, incrementing it by 1-3 in a loop, and inserting the new values.

Uploaded by

Marvin Cinco
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views2 pages

PL/SQL Code for Country and Location Queries

The document provides two code examples with missing elements. The first displays country names from a table where the country ID ranges from 51 to 55 using a loop. The second inserts three new location IDs in Montreal, Canada by getting the maximum current ID, incrementing it by 1-3 in a loop, and inserting the new values.

Uploaded by

Marvin Cinco
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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