Sunday, September 7, 2014

OBIEE How to use TIMESTAMPADD/TIMESTAMPDIFF for Date Time Period Calculation


Explanation
First Day of the Previous Year
TIMESTAMPADD( SQL_TSI_YEAR , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE))
From right to left the first TIMESTAMPADD returns the first day of the current year. The second TIMESTAMPADD removes a year from the returned date for the First Day of the Previous Year.
First Day of the Current Year
TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE)
This calculation returns the first day of the year by deducting one less than the total number of days in the year.
First Day of the Next Year
TIMESTAMPADD( SQL_TSI_YEAR , 1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE))
From right to left the first TIMESTAMPADD returns the first day of the current year. The second TIMESTAMPADD adds a year to the date returned which will give the first day of the next year.
First Day of the Previous Month
TIMESTAMPADD(SQL_TSI_MONTH, -1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))
From right to left the first TIMESTAMPADD returns the first day of the Current Month. The second TIMESTAMPADD then subtracts one month from the first day of the Current Month arriving to the First Day of the previous month.
First Day of the Current Month
TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)
This expression gets the current day of the month and subtracts one less than the current day to arrive at the first day of the month.
First Day of the Next Month
TIMESTAMPADD(SQL_TSI_MONTH, 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))
From right to left the first TIMESTAMPADD returns the first day of the Current Month. The second TIMESTAMPADD then adds one month from the first day of the Current Month arriving to the First Day of the next month.
First Day of Current Quarter
TIMESTAMPADD( SQL_TSI_DAY , DAY_OF_QUARTER( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)
This was included to show the calculations discussed above can be used with other functions. This is the same expression as the one that returns the first day of the current month except this one uses the DAY_OF_QUARTER property to return the first day of the current quarter.
Last Day of the Previous Month
TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))
From right to left the first TIMESTAMPADD returns the first day of the Current Month. The second TIMESTAMPADD subtracts a month to arrive at the first day of the previous month.
Last Day of Current Month
TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_MONTH , 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)))
From right to left the first TIMESTAMPADD finds the first day of the current Month. The second TIMESTAMPADD adds one month to the date to arrive at the first day of the next month. The final TIMESTAMPADD subtracts one day from the returned date to arrive at the last day of the Current Month.
Last Day of the Next Month
TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_MONTH , 2, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)))
From right to left the first TIMESTAMPADD finds the first day of the current Month. The second TIMESTAMPADD adds two months to the date to arrive at the first day of month after next. The final TIMESTAMPADD subtracts one day from the returned date to arrive at the last day of the Next Month.
Last Day of Previous Year
TIMESTAMPADD( SQL_TSI_DAY , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE))
From right to left the first TIMESTAMPADD returns the first day of the current year. The second TIMESTAMPADD subtracts one day to arrive at December 31st of the previous year.
Last Day of Current Year
TIMESTAMPADD(SQL_TSI_YEAR, 1, TIMESTAMPADD( SQL_TSI_DAY , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE)))
From right to left the first TIMESTAMPADD returns the first day of the current year. The second TIMESTAMPADD deducts one day to arrive at December 31 of the previous year. The third TIMESTAMPADD adds a single year to the date to arrive at December 31 of the Current Year.
Last Day of the Next Year
TIMESTAMPADD(SQL_TSI_YEAR, 2, TIMESTAMPADD( SQL_TSI_DAY , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE)))
From right to left the first TIMESTAMPADD returns the first day of the current year. The second TIMESTAMPADD deducts one day to arrive at December 31 of the previous year. The third TIMESTAMPADD adds 2 years to the date to arrive at December 31 of the Next Year.
Last Day of Current Quarter
TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_QUARTER , 1, TIMESTAMPADD( SQL_TSI_DAY , DAY_OF_QUARTER( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)))
Demonstrated using Quarters. From right to left the first TIMESTAMPADD returns the first day of the Current Quarter. The second TIMESTAMPADD returns the first day of the next quarter. The final TIMESTAMPADD subtracts a single day from the date to arrive at the last day of the Current Quarter.
Number of days between First Day of Year and Last Day of Current Month
TIMESTAMPDIFF(SQL_TSI_DAY, CAST('2010/01/01 00:00:00' AS DATE), TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_MONTH , 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))))
The second part of the TIMESTAMPDIFF uses Last Day of the Current Month calculation to force the TIMESTAMPDIFF to calculate the number of days between the first day of the year and the last day of the current month.

Saturday, September 6, 2014

Oracle Business Intelligence OBIEE 10g advanced installation with WebCenter Suite (Oracle Application Server)

There are two types of installations for OBIEE 10g.
1-     Basic Installation
2-     Advance Installation

Here we are going to install OBIEE 10.1.3.4.1 with advance installation type on windows 2003 server enterprise edition with Intel Xeon 2.3 x 2 GHz with 4 GB RAM.

Following are the pre-requisites for advanced installation type.

1-     Oracle Application Server 10.1.3.1.0 or later is required for Oracle Business Intelligence.
2-     The following Oracle Application Server components are required for Oracle Business Intelligence:
a.      Oracle HTTP Server
b.      Oracle Containers for J2EE (OC4J)
c.      Oracle Process Manager and Notification Server
NOTE: If you do not want to use Oracle HTTP Server after installing Oracle Business Intelligence Enterprise Edition, then disable Oracle HTTP Server in Oracle Application Server after the installation.
3-     Windows Login User should be “Local Administrator” of the machine. (This is to avoid any unwanted interruption during installation)


Before proceeding with the OBIEE 10g advance installation, you have to install Oracle Application Server 10.1.3.1.0 or later. For the installation and configuration of Oracle Application Server, refer to the post here

For OBIEE 10g installation, follow below steps ...

Download OBIEE 10.1.3.4.1 from here
I have  downloaded and unzipped into folder SW as shown below. 
Open folder "Server" and execute setup file ...



Click Run ...


Click Next ...


Provide the desired installation path as shown below ...


Select "Complete" ...


Provide the application server location (Refer to the post here for Oracle WebCenter Suite (Oracle Application Server) installation ...



Note:  You may encounter error "Please specify a valid Oracle Application Server 10g installation location" if your WebCenter Suite (Application Server) installation is incorrect.

To see more detail refer to:

It states:
1.4.9.16 Installer Requires the OC4J Instance to Be Named "Home" and Enabled - Advanced Option

This issue applies to Versions 10.1.3.3, 10.1.3.3.1, 10.1.3.3.2, 10.1.3.3.3, 10.1.3.4, 10.1.3.4.1, and 10.1.3.4.2.

When installing Oracle BI Enterprise Edition using the Advanced installation type, you must install Oracle Application Server before running the Oracle BI Installer. By default, Oracle Application Server creates an OC4J container called "home." This container is the location where all the Oracle BI Applications are deployed. The Oracle BI Installer requires the OC4J container called "home" to be present and enabled.

If a container called "home" does not exist, then follow the instructions located in Oracle Application Server Administration Guide to re-create the container.

If the OC4J instance named "home" is disabled, then the Oracle BI Installer does not proceed. You must enable the OC4J "home" instance for Oracle BI Installer to proceed. The Oracle BI Installer checks the existence of OC4J "home" instance and if it is enabled. If it is not, the Installer displays the following error message: "Please specify a valid Oracle Application Server 10g installation location. A valid Oracle Application Server 10g installation must have the default OC4J instance named 'home' and that 'home' OC4J instance must be enabled."

Click Next ... 


Click Next ... 



Click Next ... 


It will try to install .Net Framework 2.0. Since i have it already installed on my machine therefore it will throw error ... Nothing to worry just proceed ...








Click Finish, the installation of OBIEE 10g will be resumed ...





Click Next ...


Click Next ...


Click "Finish" to restart the machine and all should go well ...

BI URL will look alike ...
http://sampledomain:9704/analytics


Cheers ;)






Oracle WebCenter Suite 10g Advance Installation for OBIEE 10g

Below is the Oracle WebCenter Suite 10.1.3.2.0 (Application Server) advance installation on Windows 2003 Sever Enterprise Edition on 32bit hardware (Intel Xeon 2.3 x 2 GHz with 4 GB RAM).

Here are the steps …

Download Oracle WebCenter Suite 10.1.3.2.0 from here.

I have downloaded and extracted under folder SW. Run the setup file as shown below:




Provide your desired installation directory and select “Advance Installation” as show below ...


Click “Yes” and ignore the warning message and continue with the Advance Installation…


 Wait …

I have selected “WebCenter Framework with Oracle HTTP Server” because later on I want to configure this WebCenter Suite (Application Server) with OBIEE 10g which require Oracle HTTP Server as well.


Let the port configuration be automatic…


Oracle Instance Name must be named "Home" …
Provide the password and proceed to next step …


Click Next ..


Wait …


All set to install,  Click Install …


Wait for the installation to complete …





Here is the installation summary …

Congratulations! You have successfully installed Oracle WebCenter Framework with Oracle HTTP Server, part of Oracle WebCenter Suite (10.1.3.2.0).

Use the following URL to consume the Rich Text Portlet in your application:
http://sampledomain.com:80/richtextportlet/portlets/wsrp2?WSDL

Use the following URL to consume OmniPortlet in your application:
http://sampledomain.com:80/portalTools/omniPortlet/providers/omniPortlet

Use the following URL to consume Web Clipping in your application:
http://sampledomain.com:80/portalTools/webClipping/providers/webClipping

Use the following URL to access Application Server Control:
http://sampledomain.com:80/em
User Name: oc4jadmin

Use the following URL to view the Welcome Page:
http://sampledomain.com:80/index.html



These instructions are located in D:\OracleAS\10.1.3.2.0\OracleAS_1\install\readme.txt for your future reference.

You can view the status of the server with the following command:
D:\OracleAS\10.1.3.2.0\OracleAS_1\opmn\bin\opmnctl status -l

Installation Details:

Installation Directory:
D:\OracleAS\10.1.3.2.0\OracleAS_1

Installation Type:
Oracle WebCenter Framework with Oracle HTTP Server

Installed Components:
Oracle HTTP Server,
Oracle Containers for J2EE (OC4J),
Oracle WebCenter Framework,
Oracle Enterprise Manager Application Server Control,
Oracle Process Manager & Notification Server (OPMN),
Instance Name: Home.bah-bistpdev1.menacorp.com
SSL Port Number: 443

Documentation:

Online documentation for Oracle Application Server is available at:
http://www.oracle.com/technology/documentation/appserver1013.html

In order to keep your system up-to-date we encourage you to regularly check for the latest certification and software updates via Oracle Metalink.

Oracle Metalink (http://metalink.oracle.com) will help you get the most out of your Oracle products by providing access to technical information and assistance from Oracle Support Services, including information about: product availability, certification, product alerts, bug information, patches, technical solutions, logging service requests, and more.