Professional Documents
Culture Documents
com/academy
m
er as
Declared by the programmer for queries that return more than
Explicit
one row
co
eH w
o.
cursor A label for a context area or a pointer to the context area
rs e
ou urc
Disables a cursor, releases the context area, and undefines the
CLOSE
active set
o
aC s
SQL statement
fetch cursor to the next row either until there are no more rows or until
a specified condition is met
Try It / Solve It
Copyright © 2016, 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.
https://www.coursehero.com/file/31136631/PLSQL-5-1-Practicedocx/
2
1. In your own words, explain the difference between implicit and explicit cursors.
Implicit is created by the database when certain evens happen and explicit is user
define but can hold multiple rows
2. Which SQL statement can use either an explicit or an implicit cursor, as needed?
select
m
er as
co
eH w
o.
4. Identify three guidelines for declaring and using explicit cursors.
rs e
ou urc
Key words suc as open cursor fetch and close
Write with indentation
Declare variables used to fetch with %type.
o
aC s
vi y re
ed d
ar stu
5. Write a PL/SQL block to read and display the names of world regions, with a count of the
number of countries in each region. Include only those regions having at least 10 countries.
Order your output by ascending region name.
sh is
Th
Copyright © 2016, 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.
https://www.coursehero.com/file/31136631/PLSQL-5-1-Practicedocx/
3
DECLARE
CURSOR holiday_cursor IS
SELECT country_name, national_holiday_date, national_holiday_name
FROM countries
WHERE region_id=5;
v_country_name countries.country_name%TYPE ;
v_holiday countries.national_holiday_date%TYPE;
v_name countries.national_holiday_name%TYPE; BEGIN
m
er as
OPEN holiday_cursor ;
LOOP
co
eH w
FETCH holiday_cursor INTO v_country_name, v_holiday, v_name;
EXIT WHEN holiday_cursor%NOTFOUND; DBMS_OUTPUT.PUT_LINE(v_country_name||'
o.
'||v_holiday||' '||v_name);
END LOOP; rs e
ou urc
CLOSE holiday_cursor;
END
o
aC s
vi y re
ed d
ar stu
sh is
Th
Copyright © 2016, 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.
https://www.coursehero.com/file/31136631/PLSQL-5-1-Practicedocx/