Procedure/Function To calculate next business day excluding weekends and holidays

Problem Statement:

From the given date, write a function/procedure to calculate the next business day. The new returned date should not be in (SAT, SUN or Holidays).

e.g.: if the given date is 07-oct-2011, the next business day should be 11-oct-2011. Since 10-oct-2011 is a holiday.


– Create a holidays list table for a  given year.

– keep the holidays dates in a list

– check the day of the given date, if it is friday then increment the day by 3 days. or else if it is Saturday then increment by 2 days or else increment by 1 day.

– check whether incremented date falls on any of the holidays, if it does, again increment the day based on the day of the week.

Here is the oracle procedure code.

CREATE OR REPLACE PROCEDURE test.sp_business_day
   CURSOR c1
      SELECT holiday_dt
        FROM t_holiday_list;

   next_business_date         DATE;
   processing_date DATE;
   day_of_the_week number;

   SELECT proc_dt
     INTO processing_date
     FROM test.t_proc_dt;


   --DBMS_OUTPUT.put_line ('day of the week from proc_dt is:'|| DAY_OF_THE_WEEK);

   if DAY_OF_THE_WEEK = '6' then -- if day is Friday, then next business is Monday.
        NEXT_BUSINESS_DATE := processing_date + 3;
        --DBMS_OUTPUT.put_line ('added 3 days to date and new date is:' || processing_date);
   elsif DAY_OF_THE_WEEK = '7' then
        NEXT_BUSINESS_DATE := processing_date + 2;
        NEXT_BUSINESS_DATE := processing_date + 1;
   end if;

   DBMS_OUTPUT.put_line ('next proc_dt is:' || NEXT_BUSINESS_DATE);

   FOR c1rec IN c1
         IF (TRUNC (NEXT_BUSINESS_DATE) = TRUNC (c1rec.holiday_dt))
           DBMS_OUTPUT.put_line ('HOLIDAY DAY FOUND:');


            if   DAY_OF_THE_WEEK = '6' then
            elsif DAY_OF_THE_WEEK = '2' then
            elsif DAY_OF_THE_WEEK = '5' then
            end if;

         END IF;


   DBMS_OUTPUT.put_line ('Next Business Day is:' || NEXT_BUSINESS_DATE);

END sp_business_day;
Posted in Uncategorized | Leave a comment

Solution to Migrate Sun Studio Rogue Wave Tools.h++ Classes to Linux Platform

Migrating from Rogue Wave (RW) Tools.h++ library which is shipped with Sun Studio Compiler to Linux Platform

                                                                                                                     Prepared by:                                                                                                                                        Prakash Mirji, HPES,                                                                                                                


Tools.h++ is one of the popular C++ class library from Rogue Wave. It is a collection of algorithms, containers, iterators and other fundamental components.  There are other libraries like dbtools.h++ as well.   The “.h++” products/libraries were combined in 2001 into the product family SourcePro C++.  Note that the tools.h++ library predated the ANSI/ISO standard for C++ language.

In 2005, Rogue Wave handed over the tools.h++ to  Apache Foundation, who have developed and packaged  into Apache C++ Standard Library project (code name, stdcxx, pronounced  “Standard C++ Library”).  It is now open sourced and can be downloaded from Apache Foundation. More details about Apache C++ Standard library can be found at

Sun Studio and RW Tools.h++ Relation

Sun ships RW tools.h++ library in two ways:

  1. Packages with Sun Studio Compiler
  2. As a separate library “”  ( separately link with the application code).

Sun continues to bundle tools.h++ just to keep the backward compatibility even though it doesn’t meet current C++ standards. Most of the tools.h++ classes/types are now available in the C++ standard library which comes with each vendor.  A list of such few classes is given below along with corresponding ISO C++ Standard Library classes.

Tools.h++ type C++ standard library type
RWCString std::basic_string
RWCTokenizer No equivalent.

Need to write our own.

RWTValHashDictionary <> std::map<T>
RWTValHashDictionaryIterator <> std::map::iterator
RWTValSlist <> std::list <T>
RWTValSlistIterator <> std::list::iterator

Migration Problem

The applications using tools.h++ from sun doesn’t compile on Linux with gcc compiler.  GCC compiler doesn’t bundle tools.h++ library similar to Sun Studio compiler. Below are the solutions to address the problem.

Migration Solution 1  (Industry Standard and Sun Recommended)

 As stated above, RW tools.h++ is a very old product, which has not had significant updates in many years. It is predated and doesn’t conformance to the C++ Standard.  Most of the functionality in the RW tools.h++ is available in Standard C++ libraries, although the programming interface is different.  (That is, if you have the code written for RW Tools.h++, it will need to be re-written).

The benefits of recoding the API with native C++ standard library mentioned below :

  1. Full conformance to the C++ Standard
  2. Code more portable ( across platform and across compiler)
  3. Native to the platform and may have better performance

It is highly recommended to re-code the applications using RW tools.h++ classes with native C++ standard library classes.

The downside of this approach is that it requires more effort to code and test the application.

Migration Solution 2

If decision is not to change the RW tools.h++ interfaces, buy the library from Rogue Wave. Or use the open source C++ Standard library (stdcxx) from Apache Foundation.

Note: On Sun platform, if applications are using other libraries from RW like dbtools.h++, then the only option is to buy the product for Linux platform. (This is the case with Fidelity application)

The downside of this approach is that application is tied to vendor and less portable.

Migration Solution 3

Download and install Oracle Solaris Studio (formerly Sun Studio) for Linux platform. It is freely available on both Solaris and Linux operating systems. More details about the product can be found at

As stated above, the Sun Studio is bundled with RW tools.h++ library. The applications coded with RW tools.h++ classes can be compiled without making any changes. However, need to pass compiler flag i.e. .‘-library=rwtools7, iostream, no%Cstd’. This tells the compiler to use Rogue Wave Tools.h++ library, use classic iostream library, and NOT to use C++ standard library.

Some customers prefer this approach. I’ve used this method at BNYM.

The downside of this approach:

  1. Application code uses non standard C++ language standards
  2. Not making use of native GCC compiler
  3. Tied to 3rd party compiler. Sun might stop shipping tools.h++ library from future versions of its compiler on Linux platform
  4. Generated binaries/libraries may not be optimized due to use of 3rd party compiler on Linux. This may result as slight performance hit.
Posted in Uncategorized | 2 Comments

Hello world!

Welcome to After you read this, you should delete and write your own post, with a new title above. Or hit Add New on the left (of the admin dashboard) to start a fresh post.

Here are some suggestions for your first post.

  1. You can find new ideas for what to blog about by reading the Daily Post.
  2. Add PressThis to your browser. It creates a new blog post for you about any interesting  page you read on the web.
  3. Make some changes to this page, and then hit preview on the right. You can alway preview any post or edit you before you share it to the world.
Posted in Uncategorized | 1 Comment