O'Reilly logo

Oracle® PL/SQL® Interactive Workbook, Second Edition by Elena Silvestrova, Benjamin Rosenzweig

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 12 Procedures

1)Write a procedure with no parameters. The procedure will let you know if the current day is a weekend or a weekday. Additionally, it will let you know the user name and current time. It will also let you know how many valid and invalid procedures are in the database.
A1: Answer: Your answer should look similar to the following:
 CREATE OR REPLACE PROCEDURE current_status AS v_day_type CHAR(1); v_user VARCHAR2(30); v_valid NUMBER; v_invalid NUMBER; BEGIN SELECT SUBSTR(TO_CHAR(sysdate, 'DAY'), 0, 1) INTO v_day_type FROM dual; IF v_day_type = 'S' THEN DBMS_OUTPUT.PUT_LINE ('Today is a weekend.'); ELSE DBMS_OUTPUT.PUT_LINE ('Today is a weekday.'); END IF; -- DBMS_OUTPUT.PUT_LINE('The time is: '|| TO_CHAR(sysdate, 'HH:MI AM')); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required