Archive | Oracle

SQL Pad Left Functionality (Oracle / SQL Server)

Every now an then one needs to pad a column value with a character or symbol in order to conform the resulting value to some standard. For example, a company may represent their stores by a maximum of 4 digits and each character in that 4-digit store number must contain a value as to not be confused with any other values..  In other words, store #99 would be represented as 0099 instead of just 99.

This is not uncommon practice. Often times, similar functionality is required when pulling data from the mainframe where “super keys” are paramount.  Our good friends at MS have set up SQL Server so that this is universally simple.  The code snippet in its basic form looks like this:

RIGHT('0000' +  [COLUMN NAME], 4)

This is straightforward.  Use the RIGHT function by concatenating the first parameter to a set number of padding characters and the column name in your table. Be sure to CAST that column as a string data type if pulling a numeric field.  Then, for the RIGHT functions second parameter, make its value the same number of character spaces required for your final value.

Oracle just had to be difficult.  In order to conduct the same operation using PL/SQL you must use a function, which I am still not sure how it completely works behind the scenes.  The syntax is as follows:

SELECT to_char([COLUMN NAME],'FM0000') AS result FROM table;

Update
Recently a reader posted the use of the Oracle function LPAD, which is much cleaner than the use of the FM function and works better than the SQL Server function. The syntax would be

SELECT LPAD('Test', 8, '0') AS result FROM dual;

This LPAD function has been relevant since 8i.

Conclusion

Each of the code snippets above will provide a conformed look at a column value.  SQL Server’s method seems to be a little more cut n’ dry than PL/SQL’s but they both get the job done.

Another great source for Oracle functions can be found at http://www.techonthenet.com/oracle/functions/lpad.php

Posted in Business Intelligence, Database, Tricks n' TipsComments (1)

OBI Time Dimension Weeks In a Month - Prototype Hack

I was looking to create a formula that required averaging based on the number of week in the given month. As an example Monthly Sales Total / # Weeks In Month.  Since this is a fiscal calendar the weeks are usually standardized and shouldn’t change that often.  So, if the fiscal calendar is on a 4-4-5 or 4-5-4 the logic is rather straightfoward.

I couldn’t make changes to the underlying Calendar dimension table and I couldn’t recall how to do this programmatically in OBI so I went with what I will call a quick prototyping hack.  Here it is below.

CASE  WHEN “Indirect Sales”.DIM_TIME.MONTH_NUMBER IN (3, 6, 9, 12) THEN 5 ELSE 4 END

This worked out perfectly as a place holder as we can see by a quick ad-hoc look at the new calculated measure.

If anyone has the right or clever way of doing this leave a comment.

Posted in Business Intelligence, OBIEEComments (1)

OBIEE Error Codes: GOA4AK7Z (Cube Definition is invalid…)

Working in OBI  Answers you will probably run into this code every now and again.  I typically bump into this error when I do a “Save As..” of an existing Answers view/report to create a new report built on only a few of the metrics which the original report was built.  The full error is: Cube Definition is invalid (Measure out of bounds) Error Codes: GOA4AK7Z.

Cause:
This error is displayed because the pivot table or view that was previously referenced no longer contains the metric selection that previously was chosen. More to the point, the view no longer contains any reference to a metric. This error mainly arises when using the pivot table view as the other views have default references that bind successfully when parsed.

Solution:
Quite simple actually. Just select the Criteria tab in the Answers window. Click the view drop-down and choose the pivot table view in question (Edit the Pivot Table). When the pivot table edit page opens you will see that the Measures box within the pivoting criteria window is empty. Move a metric from the ‘Excluded’ criteria box to the ‘Measures’ box and you should be good to go.

Here is the problem as shown when the pivot table is referenced after getting this error and then choosing to edit pivot table.

In lieu of this solution one could also just scrap the answers report and recreate it. However, it is best to identify and understand why the problem occurring, thus fixing it and preventing it from happening.

Posted in ErrorsComments (1)

Row Count for all Tables

Recently a client wanted all the row counts from specific tables on a given scheme.  The list of tables to have their row counts documented was at about 50, which accounted for about 90% of the table objects in the scheme.  At first I was going to use the “Update Row Count” feature in OBI as this is where the project was grounded.  Then, I thought there had to be an easier approach.  Using the script below I was able to get the counts and simply eliminate the objects that where in the not needed 10%. The database we were using is Oracle so the PL/SQL won’t work for MS SQL Server. I will try to find the old SQL Server code I used to do this on a previous project and post it here as well at a later time.


set serveroutput on
declare
row_cnt number;
begin
for x in (select table_name
from user_tables
order by table_name) loop
execute immediate
'select count(*) from '
||x.table_name into row_cnt;
dbms_output.put_line(rpad(x.table_name,30)||lpad(to_char(row_cnt),7));
end loop;
end;
/

a variation of this is:

Set heading off
Set feedback off
Set pagesize 0
Set termout off
Set trimout on
Set trimspool on
Set recsep off
Set linesize 100
Column d noprint new_value date_
Column u noprint new_value user_
Spool tmp
Select 'Select '''||table_name||' : ''||count(*) from '||table_name||';',
to_char(sysdate, 'YYYYMMDDHH24MISS') d, user u
from user_tables
order by table_name
/
Spool off
Spool count_&user_._&date_
@tmp.LST
Spool off

References:

http://vivekagarwal.wordpress.com/2007/07/17/how-to-determine-row-count-for-all-tables-in-an-oracle-schema/
http://www.tek-tips.com/viewthread.cfm?qid=1393349&page=23

Posted in Business Intelligence, Database, OracleComments (1)

OBIEE, Corda PopChart, and SQL Anywhere - Underrated Third Party Tools

Searching for some answers to an OBIEE issue a client was having led me through an extremely detailed excursion through the OracleBI andOracleBIData file system folder structures.  I bumped into the folder /OracleBI/Corda50/ which I hadn’t paid much attention to in the past.  This is where things got interesting.  Spelunking through that directory led me to http://www.corda.com, which low and behold is the owner of the PopChart software technology that OBIEE uses to render its charting graphics - all formats of all charts and graphs.

This PopChart technology is the core reason we have the seemingly superfluous Oracle BI Java Host service that we have all come to love/hate.  It is Java based and clearly fits directly into OBIEE’s infrastructure model.  Okay, so now that you now have that tid-bit in your arsenal, here are few questions that one could ask of their dev skills or conjecturing minds:

  1. Why do the charts that PopChart show on their website look cooler than what OBIEE offers?  Could one download a trial, rip the new PopChart version binaries, and swap them in the /Corda50/ folder?
  2. Why didn’t Oracle throw in the cool Corda mapping chart?  It would beat MapViewer any day.
  3. Is PopChart the engine that we should expect to run graphs/charts in OBIEE 11G?
  4. What licensing deal did Oracle set-up to get Corda PopChart in OBIEE?  It had to be a sweet deal for Corda.

Next up in the third party tool battery is a tool that Oracle BI leverages in a more ancillary fashion, SQLAnywhere.  If you haven’t heard of it before don’t worry, there’s only 10 Million or so copies in use  : ) .  SQLAnywhere is owned by Sybase. And as far as I know, even though Sybase had a stellar year in 2008 they have not yet been acquired by an larger firm like let’s say…Oracle.  Although Oracle did have Sybase on their acquisition list back in 2004 during the PeopleSoft takeover helmed by a younger Ellison.

For those of us that have actually completed a Oracle BI Disconnected Analytics implementation you will immediately know (well, you should) that SQLAnywhere is the database for disconnected analytics.  When installing Disconnected Anlaytics as part of a client tools install you get a folder within the OracleBI folder structure called SQLAnywhere.  I eventually plan on doing a Disconnected Analytics Tutorial just to show how it works from a client’s laptop, using Briefing Books, connecting to a local dashboard, etc in a later post.  BTW, SQLAnywhere looks for a “.db” extension for its database file. Without the .db file there is nothing in that default folder to query.

Conclusion

This post is about more that just rambling tid-bits.  It seeks to gain insight into the inner workings of OBIEE.  Let’s face the facts, the cost per license seat for Corda PopChart and SQLAnywhere are not cheap.  You can look it up yourself.   What’s more interesting is Oracle’s no to long ago purchase of Sun Microsystems who had purchased MySQL not to long before that.  Will MySQL replace Oracle BI’s use of SQLAnywhere?  I belive so.  MySQL is much more widely adopted and it is still open-source.  And, what about Corda PopChart?  We’ll soon see who gets the chart and graphs rendering job in Oracle BI 11G but I suspect that it won’t be Corda.  Why my suspicion? Just look at the screenshots from the upcoming 11G Answers preview and look at the Corda PopCharts website, if they did get the gig, they must have done some custom work which I would have brought in-house if I was Oracle BI development management.  Plus, there are some nice open source graphing tools out there, just do a Google search to find them.

All in all I think 11G will make us re-think what we know about OBIEE.  It is going to give us bloggers a lot more content to write about that’s for sure.

Credits

Screenshot for OBIEE 11G

Posted in Business Intelligence, Disconnected Analytics, News, OracleComments (6)

OBIEE Content Accelerator Framework(CAF) Usage Matrix

My last blog post on CAF primarily introduced our readers to the Oracle Content Accelerator Framework and its installation.  As part of my deeper dive I find that one key reference to using CAF properly is understanding the requirements for when a web catalog and/or RPD must be online or offline when cloning and synchronizing.  Therefore, as one of the first posts for the CAF deeper dive I am providing the matrix below as visual guide for what status a source or target web catalog and RPD must have  in order for CAF to work its magic.

Basically,  if the clone function is used, the RPDs for both the source and target must be offline.  The web catalog for the source can either be online or offline but the target web catalog must be online.   If you are using the synchronize function of CAF v1, then it doesn’t matter what the status of the source (selected) web catalog is as it can be online or offline.   However, since a the whole point of using synchronize is to compare an old RPD with a new RPD based on changes to logical columns and presentation layer columns and then modify the target RPD file, the target RPD must be Offline.  However, the original RPD (backup or early stage environment file) must also be offline due to some read/write functionality.

Posted in CAF, OBIEE, OracleComments (0)

OBIEE Usage Tracking - Install in < 20 minutes

If you haven’t explored the full depth of OBIEE and all of its majestic glory then you may have not yet seen the 10.1.3.4 sample RPD and web catalog which can integrate with your RPD to track user access statistics, longest running queries, etc. By the way Oracle aptly named this Usage Tracking. This is a fantastic tool and below I have put together the web’s first video tutorial on how to install and configure the basics of the Usage Tracking RPD. In subsequent posts I look to explore Usage Tracking in more detail as well as to show you how to migrate the schema from the basic, dare I say lonely Usage Tracking RPD, and integrate it with a more real world scenario RPD like the one your company runs its supply chain analytics from. The video is below - enjoy.

Remember, the toll for watching this video is simply to leave a comment. If you learn anything from the video then you must leave a comment and praise it heavily. : )

How to Install OBIEE Usage Tracking < 20 min from ArtOf BI on Vimeo.

Posted in Business Intelligence, OBIEE, Tutorials, VideoComments (5)

Scripting OBIEE with UDML/XML (XUDML Automation?)

After my recent post on the Content Accelerator Framework and preparing for my deeper dive into the tool, I have begun looking at the inner workings of how to automate the tool for daily or weekly maintenance tasks.  This effort got me looking at some possible linkages between CAF and some existing OBIEE executables, nqXUDMLGen.exe and nqXUDMLExec.exe that reside in the ORACLEBI_HOME\Server\bin\ directory.

Andreas from Trivadis has done a spectacular job detailing the usage of XUDML in OBIEE, here.  I have also mirrored it here.

I should be posting my additional CAF findings this month.

Trivadis also has some other cool docs on BI which I have mirrored below:

Posted in CAF, ETL, PotpourriComments (1)

OC4J Windows Service Configuration

In my previous post on Essbase Studio Server & OC4J as a Windows Service I mainly tailored that information to Essbase Studio.  I received a bit of feedback on making sure I added the OC4J component in a similar fashion and here it is.  Don’t forget to watch the video tutorial for full disclosure.

Installation

Here is the OC4J Windows Service files download.

I recommend extracting the Zip file to the following root path, ORACLEBI_HOME\server\.

Similar to the Essbase Studio windows service files you will need to update the RegisterService.bat and ServiceRegistration.reg files to point to your installation’s correct OC4J file paths.  Once that has been confirmed execute the _init_BuildAppAsWinServiceWrapper.bat to launch the process.  Click ‘OK’ for all registry update prompts.

Gotchas

There are no gotchas to this solution that I have yet found.  If you spy any please leave a comment and I will seek to provide an update.  The main thing to note is that this solution was developed for the 10.1.3.4 release of OBIEE which is the 10.1.3.1.0 release of OC4J and the Embedded Java Containers.  If you run the following command in a command window you will be able to see the version of OC4J that your machine is running:

  • ORACLEBI_HOME\oc4j_bi\bin\oc4j.cmd -version

Conclusion

Again, once one knows how to use the inherent code for Windows Servers it is actually quite straightforward to implement this type of solution.

Posted in OBIEE, OC4J, Oracle, TutorialsComments (3)

Essbase Studio Server or OC4J as a Windows Service - (How-to Video)

As promised, based on my previous post regarding setting up Essbase Studio Server and OC4J to run as a Windows Service, I have provided a video to visually assist you with your integration.

Essbase Studio Server & OC4J As a Windows Service from ArtOf BI on Vimeo.

If you have any questions or comments please post them so that everyone can benefit from them.

Posted in Business Intelligence, Hyperion, OBIEE, OC4J, Studio, Tutorials, VideoComments (2)