Database Programming With PL/SQL 6-2: Practice Activities: Using Explicit Cursor Attributes

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

www.oracle.

com/academy

Database Programming with PL/SQL


6-2: Using Explicit Cursor Attributes Practice
Activities
Vocabulary
Identify the vocabulary word for each definition below:
%ISOPEN Returns the status of the cursor

%ROWCOUNT An attribute that processes an exact number of rows or counts the


number of rows fetched in a loop
%NOTFOUND An attribute used to determine whether the most recent FETCH
statement successfully returned a row

Try It/Solve It
1. In your own words, explain the advantage of using %ROWTYPE to declare a record structure
based on a cursor declaration.
Con este comando podemos ahorrarnos muchos Dolores de cabeza evitando errores basados en
distintos tipos de datos.
2. Write a PL/SQL block to read through rows in the countries table for all countries in region 5 (South
America region). For each selected country, display the country_name,
national_holiday_date, and national_holiday_name. Use a record structure to hold all the columns
selected from the countries table.
DECLARE
CURSOR cur_countries IS SELECT COUNTRY_NAME, national_holiday_date,
national_holiday_name FROM countries;
v_cou_record cur_countries%ROWTYPE;
BEGIN
OPEN cur_countries;
LOOP
FETCH cur_countries INTO v_cou_record;
EXIT WHEN cur_countries%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(v_cou_record.COUNTRY_NAME || ' ' ||
v_cou_record.national_holiday_date || ' ' ||
v_cou_record.national_holiday_name);
END LOOP;
CLOSE cur_countries;
END;
Hint: This exercise is similar to question 4G in the previous lesson. Use your solution as a starting
point for this exercise.

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.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy