Question: Automates standard cursor-handling operations such as OPEN, FETCH, %NOTFOUND, and CLOSE so that they do not need to be coded explicitly Try It / Solve

Automates standard cursor-handling operations such as OPEN, FETCH, %NOTFOUND, and CLOSE so that they do not need to be coded explicitly

Try It / Solve It

1. Describe two benefits of using a cursor FOR loop.

3. Modify your answer to question 2 to declare the cursor using a subquery in the FORLOOP statement, rather than in the declaration section. Test your changes again.

4. Using the COUNTRIES table, write a cursor that returns countries with a highest_elevation greater than 8,000 m. For each country, display the country_name, highest_elevation, and climate. Use a cursor FOR loop, declaring the cursor using a subquery in the FORLOOP statement.

5. This question uses a join of the SPOKEN_LANGUAGES and COUNTRIES tables with a GROUP BY and HAVING clause. Write a PL/SQL block to fetch and display all the countries that have more than six spoken languages. For each such country, display country_name and the number of spoken languages. Use a cursor FOR loop, but declare the cursor explicitly in the DECLARE section. After all the rows have been fetched and displayed, display an extra row showing the total number of countries having more than six languages. (Hint: Declare a variable to hold the value of %ROWCOUNT.)

6. Why did your block in question 4 need to declare the cursor explicitly, instead of declaring it as a subquery in the FORLOOP statement?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!