October 2002
Intermediate to advanced
688 pages
14h 14m
English
| 1) | Rewrite script ch08_1a.sql using a WHILE loop instead of a simple loop. Make sure that the output produced by this script does not differ from the output produced by the script ch08_1a.sql. |
| A1: |
Answer: Consider the script ch08_1a.sql:
SET SERVEROUTPUT ON
DECLARE
v_counter BINARY_INTEGER := 0;
BEGIN
LOOP
-- increment loop counter by one
v_counter := v_counter + 1;
DBMS_OUTPUT.PUT_LINE ('v_counter = '||v_counter);
-- if EXIT condition yields TRUE exit the loop
IF v_counter = 5 THEN
EXIT;
END IF;
END LOOP;
-- control resumes here
DBMS_OUTPUT.PUT_LINE ('Done…');
END; Next, consider a new version of the script that uses a WHILE loop. All changes are shown in bold letters. SET SERVEROUTPUT ON DECLARE v_counter BINARY_INTEGER ... |
Read now
Unlock full access