Question: Using the 'countries' table: a . Write a PL / SQL block to iterate through the 'countries' table for all countries in region 5 (
Using the 'countries' table:
a Write a PLSQL block to iterate through the 'countries' table for all countries in region South America For each country, display the 'country name', 'national holiday date', and 'national holiday name'. Use a record structure to hold the selected columns.
Name the cursor 'yourfirstname countries cur'.
Write your complete PLSQL code here. This is my code but getting an error
DECLARE
CURSOR yourfirstnamecountriescur IS
SELECT countryname, nationalholidaydate, nationalholidayname
FROM countries
WHERE regionid ;
countryrec yourfirstnamecountriescurROWTYPE;
BEGIN
OPEN yourfirstnamecountriescur;
LOOP
FETCH yourfirstnamecountriescur INTO countryrec;
EXIT WHEN yourfirstnamecountriescurNOTFOUND;
DBMSOUTPUT.PUTLINECountry: countryrec.countryname
National Holiday Date: TOCHARcountryrec.nationalholidaydate, DDMONYYYY
National Holiday Name: countryrec.nationalholidayname;
END LOOP;
CLOSE yourfirstnamecountriescur;
END;
b Modify the code to use a cursor FOR loop, retaining the explicit cursor declaration in the 'DECLARE' section. Test your changes.
Write your complete PLSQL code here. This is my code but also getting an error.
DECLARE
CURSOR yourfirstnamecountriescur IS
SELECT countryname, nationalholidaydate, nationalholidayname
FROM countries
WHERE regionid ;
BEGIN
FOR countryrec IN yourfirstnamecountriescur LOOP
DBMSOUTPUT.PUTLINECountry: countryrec.countryname
National Holiday Date: TOCHARcountryrec.nationalholidaydate, DDMONYYYY
National Holiday Name: countryrec.nationalholidayname;
END LOOP;
END;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
