Header Ads Widget

Module 07: Using Explicit Cursors

Using Explicit Cursors


01. You want to create a cursor that can be used several times in a block. Selecting a different active set each time that it is opened.

Which type of cursor do you create?

a. A cursor for loop.

b. A multiple selection cursor.

c. A cursor for each active set.

d. A cursor that uses parameters.

Answer: d

02. Which statement is true when writing a cursor for loop?

a. You must explicitly fetch the rows within a cursor for loop.

b. You must explicitly open the cursor prior to the cursor for loop.

c. You must explicitly close the cursor prior to the end of program.

d. You do not explicitly open, fetch or close a cursor within a cursor for loop.

e. You must explicitly declare the record variable that holds the row returned from the cursor.

Answer: d

03. Given the executable section of a PL/SQL block

FOR employee_record IN salary_cursor LOOP

employee_id_table (employee_id) := employee_record.last_name;

END LOOP

CLOSE salary_cursor;

END;

Why does this section cause an error?=

a. The cursor needs to be opened.

b. Terminating conditions are missing.

c. No FETCH statements were issued.

d. The cursor does not need to be explicitly closed.

Answer: d

04. What should you do after each fetch statement in the PL/SQL block?

a. Open the cursor.

b. Close the cursor.

c. Initialize the loop.

d. Test for the rows using the cursor attribute.

Answer: d

05. Under which situation it is necessary to use an explicit cursor?

a. When any DML or select statement is used in a PL/SQL block.

b. When a delete statement in a PL/SQL block deletes more than one row.

c. When a select statement in a PL/SQL block is more than one row.

d. When an update statement in a PL/SQL block has to modify more than one row.

Answer: c

06. When using an explicit cursor, after which statement should, you test to see if the cursor contains rows?

a. OPEN.

b. FETCH.

c. CLOSE.

d. CURSOR.

Answer: b

07. Which value is stored in %NOTFOUND if the query will return two rows and the first FETCH statement has been issued?

a. TRUE.

b. NULL .

c. FALSE.

d. NONE.

Answer: c

08. When controlling explicit cursors, which statement calls the rows identified by the query to the active set? 

a. OPEN.

b. FETCH.

c. CLOSE.

d. CURSOR.

Answer: a

09. When controlling an explicit cursor, which statement contains the INTO clause? 

a. OPEN.

b. FETCH.

c. CLOSE.

d. CURSOR.

Answer: b

10. Which value is stored in %ROWCOUNT if the query will return two rows and the third FETCH statement has been issued?

a. 0

b. 2

c. 3

d. NULL.

Answer: b

11. Which value is stored in %ROWCOUNT before the cursor is opened?

a. 0

b. NULL .

c. TRUE.

d. FALSE.

Answer: a

12. Which cursor attribute evaluates to TRUE when an unsuccessful fetch has occurred?

a. %FOUND.

b. %ISOPEN.

c. %NOTFOUND.

d. %ROWCOUNT.

Answer: c

Post a Comment

0 Comments