Skip to Content
Oracle PL/SQL Programming: A Developer's Workbook
book

Oracle PL/SQL Programming: A Developer's Workbook

by Steven Feuerstein, Andrew Odewahn
May 2000
Intermediate to advanced
594 pages
11h 32m
English
O'Reilly Media, Inc.
Content preview from Oracle PL/SQL Programming: A Developer's Workbook

Expert

19-17.

Write a function that returns the date of the nearest day named to the specified date, as in:

FUNCTION nearestday (
   yourdate IN DATE,
   dayname  IN VARCHAR2)
RETURN DATE;

19-18.

Write a function to return the number of business days (defined in this exercise as all days that are not Saturdays and Sundays) between two dates. Here is the header:

FUNCTION bizdays_between (
   start_date IN DATE, end_date IN DATE)
   RETURN INTEGER;

19-19.

Enhance the “business days between” function to also subtract from total the number of holidays stored in the following table:

CREATE TABLE holiday (dt DATE);

19-20.

Write a function that returns the nth named day in the month in which the specified date is located. Here is the header for such a function:

FUNCTION nthday (
   yourdate IN DATE,
   dayname  IN VARCHAR2,
   nthday   IN INTEGER)
RETURN DATE;

and here is the expected behavior:

SQL> EXEC DBMS_OUTPUT.PUT_LINE(nthday(SYSDATE,'monday',1))
February 1, 1999 00:00:00
SQL> EXEC DBMS_OUTPUT.PUT_LINE(nthday(SYSDATE,'monday',2))
February 8, 1999 00:00:00
SQL> EXEC DBMS_OUTPUT.PUT_LINE(nthday(SYSDATE,'monday',3))
February 15, 1999 00:00:00
SQL> EXEC DBMS_OUTPUT.PUT_LINE(nthday(SYSDATE+30,'monday',5))
March 29, 1999 00:00:00

19-21.

I discovered recently (March 1999) that the documented maximum allowable date in PL/SQL had changed from the long-standing December 31, 4712. How did I discover this? A visitor to the PL/SQL Pipeline found that he could work with dates well beyond this “limit.” He wondered what the actual limit ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Oracle Database 11g PL/SQL Programming Workbook

Oracle Database 11g PL/SQL Programming Workbook

Michael McLaughlin, John Harper

Publisher Resources

ISBN: 9781449324070Supplemental ContentErrata Page