100% found this document useful (1 vote)
6K views

Using Explicit Cursor Attributes

This document contains a quiz with 7 multiple choice questions about explicit cursor attributes in PL/SQL. The questions cover topics such as: referencing explicit cursor attributes in SQL statements; referencing fields in a PL/SQL record; cursor attributes that evaluate to TRUE if the most recent FETCH returns a row; the data type of a variable declared using %ROWTYPE; displaying values fetched from a cursor; exiting a FETCH loop after a certain number of rows; and the number of fields contained in a variable declared using %ROWTYPE on a cursor that joins two tables. The document tests the user's knowledge of how to work with explicit cursors in PL/SQL.

Uploaded by

Catalina Achim
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
6K views

Using Explicit Cursor Attributes

This document contains a quiz with 7 multiple choice questions about explicit cursor attributes in PL/SQL. The questions cover topics such as: referencing explicit cursor attributes in SQL statements; referencing fields in a PL/SQL record; cursor attributes that evaluate to TRUE if the most recent FETCH returns a row; the data type of a variable declared using %ROWTYPE; displaying values fetched from a cursor; exiting a FETCH loop after a certain number of rows; and the number of fields contained in a variable declared using %ROWTYPE on a cursor that joins two tables. The document tests the user's knowledge of how to work with explicit cursors in PL/SQL.

Uploaded by

Catalina Achim
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

Test: Quiz: Using Explicit Cursor Attributes 1.

You can reference explicit cursor attributes directly in a SQL statemen t. True or False? Mark for Review (1) Points True False (*)

Correct 2. How must you reference one field which is part of a PL/SQL record? Mark for Review (1) Points field_name.record_name record_name.field_name (*) record_name(field_name) field_name OF record_name It cannot be done.

Correct 3. Which of the following explicit cursor attributes evaluates to TRUE if the most recent FETCH returns a row? Mark for Review (1) Points %ISOPEN %NOTFOUND %FOUND (*) %ROWCOUNT

Correct 4. Look at the following code:

DECLARE CURSOR emp_cursor IS SELECT employee_id, last_name, salary FROM employees; v_empcurs emp_cursor%ROWTYPE; What is the data type of V_EMPCURS? Mark for Review (1) Points Scalar Record (*) Cursor Row

Correct 5. Examine the following code: DECLARE CURSOR country_curs IS SELECT country_id, country_name FROM wf_countries ORDER BY country_name; v_country country_curs%ROWTYPE; BEGIN OPEN country_curs; LOOP FETCH country_curs INTO v_country; EXIT WHEN country_curs%NOTFOUND; ------- Line A END LOOP; CLOSE country_curs; END; You want to display the id and name of each FETCHed country. What would you code at Line A? Mark for Review (1) Points DBMS_OUTPUT.PUT_LINE(country_id || ' ' || country_name); DBMS_OUTPUT.PUT_LINE(v_country(country_id) || ' ' || v_country(country_n ame)); DBMS_OUTPUT.PUT_LINE(country_curs.country_id || ' ' || country_curs.coun try_name);

DBMS_OUTPUT.PUT_LINE(v_country.country_id || ' ' || v_country.country_na me); (*)

Correct 6. You have declared the following cursor: CURSOR country_curs IS SELECT * FROM wf_countries ORDER BY country_name; There are over 200 rows in the WF_COUNTRIES table, but you want to fetch and dis play only the first 25 rows. How would you exit from the FETCH loop? Mark for Review (1) Points EXIT WHEN country_curs%FOUND(25); EXIT WHEN country_curs%ROWCOUNT > 25; (*) EXIT WHEN ROWCOUNT > 25; WHEN country_curs > 25 THEN EXIT; END IF;

Correct 7. Look at these declarations: DECLARE CURSOR dept_loc_cursor IS SELECT department_id, department_name, location_name FROM departments d, locations l WHERE d.location_id = l.location_id; v_dept_loc dept_loc_cursor%ROWTYPE; How many fields does V_DEPT_LOC contain? Mark for Review (1) Points Two, because the cursor joins two tables Four Three (*)

None

Correct

You might also like