Chapter 6 Conditional Control: CASE Statements
1) | Create the following script. Modify the script created in this section in Chapter 5 (Question 1 of the Test Your Thinking section). You can use either the CASE statement or the searched CASE statement. Your output should look similar to the output produced by the example created in Chapter 5. |
A1: |
Answer: Consider the script created in the section in
Chapter 5:
SET SERVEROUTPUT ON DECLARE v_day VARCHAR2(15); v_time VARCHAR(8); BEGIN v_day := TO_CHAR(SYSDATE, 'fmDAY'); v_time := TO_CHAR(SYSDATE, 'HH24:MI'); IF v_day IN ('SATURDAY', 'SUNDAY') THEN DBMS_OUTPUT.PUT_LINE (v_day||', '||v_time); IF v_time BETWEEN '12:01' AND '24:00' THEN DBMS_OUTPUT.PUT_LINE ('It''s afternoon'); ELSE DBMS_OUTPUT.PUT_LINE ... |
Get Oracle® PL/SQL® Interactive Workbook, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.