Write a PL/SQL block
Answer: Your answer should look similar to the following:
SET SERVEROUTPUT ON DECLARE -- A VARCHAR2 datatype that can contain the string -- 'Introduction to Oracle PL/SQL' v_descript VARCHAR2(35); -- A NUMBER that allows for the conditions: can be assigned -- 987654.55 but not 987654.567 or 9876543.55 v_number_test NUMBER(8,2); -- [a variable] auto initialized to the value '603D' v_location CONSTANT VARCHAR2(4) := '603D'; -- A BOOLEAN v_boolean_test BOOLEAN; -- A DATE datatype auto initialized to one week from today v_start_date DATE := TRUNC(SYSDATE) + 7; BEGIN DBMS_OUTPUT.PUT_LINE ('The location is: '||v_location||'.'); DBMS_OUTPUT.PUT_LINE ('The starting date is: '||v_start_date||'.'); END;
Alter the PL/SQL block you created in above to conform to the following specs.
Answer: Your answer should look similar to the following:
SET SERVEROUT ON DECLARE -- A VARCHAR2 datatype that can contain the string 'Introduction -- to Oracle PL/SQL' v_descript VARCHAR2(35); -- A NUMBER that allows for the conditions: can be assigned -- 987654.55 but not 987654.567 or 9876543.55 v_number_test NUMBER(8,2); -- [a variable] auto initialized to the value '603D' v_location CONSTANT VARCHAR2(4) := '603D'; -- A BOOLEAN v_boolean_test BOOLEAN; -- A DATE datatype auto initialized to one week from today v_start_date DATE := TRUNC(SYSDATE) + 7; BEGIN IF v_descript = 'Introduction to Underwater Basketweaving' THEN DBMS_OUTPUT.PUT_LINE ('This course is '||v_descript||'.'); ELSIF v_location = '603D' THEN -- No value has been assigned to v_descript IF v_descript IS NOT NULL THEN DBMS_OUTPUT.PUT_LINE ('The course is '||v_descript ||'.'||' The location is '||v_location||'.'); ELSE DBMS_OUTPUT.PUT_LINE ('The course is unknown.'|| ' The location is '||v_location||'.'); END IF; ELSE DBMS_OUTPUT.PUT_LINE ('The course and location '|| 'could not be determined.'); END IF; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE ('An error occurred.'); END;