nerdexam
Oracle

1Z0-882 · Question #23

You create a table and a stored procedure: CREATE TABLE t1 (f1 int); INSERT INTO t1 VALUES (1), (2) , (3), (4), (5); CREATE PROCEDURE sum_t1() BEGIN DECLARE done INT DEFAULT 0; DECLARE va1 INT…

The correct answer is D. An infinite loop will be running until the command is killed. See the full explanation below for the reasoning.

Question

You create a table and a stored procedure:

CREATE TABLE t1 (f1 int); INSERT INTO t1 VALUES (1), (2) , (3), (4), (5); CREATE PROCEDURE sum_t1() BEGIN DECLARE done INT DEFAULT 0; DECLARE va1 INT; DECLARE result CURSOR FOR SELECT f1 FROM t1; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=1; OPEN cur; REPEAT FETCH cur INTO va1; IF NOT done THEN SET result = result +va1; END IF:

UNTIL done END REPEAT; SELECT result; END CALL sum_t1(); What is the result of the CALL statement?

Options

  • AThe procedure completes, and 15 is returned
  • BThe procedure's IF condition is not satisfied, and 0 is returned.
  • CThe procedure's loop is not entered, and 1 is returned.
  • DAn infinite loop will be running until the command is killed.

How the community answered

(67 responses)
  • A
    7% (5)
  • B
    12% (8)
  • C
    4% (3)
  • D
    76% (51)

Community Discussion

No community discussion yet for this question.

Full 1Z0-882 Practice