Saturday, February 19, 2011

ORA-02298 cannot enable constraint - parent keys not found

Problem Description
After you export user schema(s) as user SYS with consistent=yes, you import dump file into database and an Oracle ORA-2298 error is generated. The user schema(s) do not have referenced constraints to other schemas.
From import log following errors found.
ORA-02293: cannot validate (A.CheckConstraint) - check constraint violated, and
ORA-02298: cannot validate (A.ChangesFK) - parent keys not found

Solution of the Problem
If you export any schema as user SYS then simply CONSISTENT parameter is ignored and it is used as CONSISTENT=n whatever value you provide.

According to Oracle documentation, CONSISTENT=y is unsupported for exports that are performed when you are connected as user SYS or you are using AS SYSDBA, or both.

So if you want to make consistent export then use any other user rather than SYS, for example export as SYSTEM user and use CONSISTENT=y.

However, if your database is big enough once you import data into your database you might not consider re-export dump from source database. Rather either you want to delete orphan child rows from then child table or insert missing rows in the parent table.

In order to find out missing values into the parent table use the following query.
select  'select '||cc.column_name-
        ||' from '||c.owner||'.'||c.table_name-
        ||' a where not exists (select ''x'' from '-
        ||r.owner||'.'||r.table_name-
        ||' where '||rc.column_name||' = a.'||cc.column_name||')'
from    dba_constraints c,
        dba_constraints r,
        dba_cons_columns cc,
        dba_cons_columns rc
where   c.constraint_type = 'R'
and     c.owner not in ('SYS','SYSTEM')
and     c.r_owner = r.owner
and     c.owner = cc.owner
and     r.owner = rc.owner
and     c.constraint_name = cc.constraint_name
and     r.constraint_name = rc.constraint_name
and     c.r_constraint_name = r.constraint_name
and     cc.position = rc.position
and     c.owner = '&table_owner'
and     c.table_name = '&table_name'
and     c.constraint_name = '&constraint_name'
/

The output of this query will be select statement. Copy and paste the output back into sqlplus which will list all of the values that are missing in the parent table.

In order to remove the rows from the child table which contain values that are not in the parent table run the following query,
select  'delete from '-
        ||c.owner||'.'||c.table_name-
        ||' a where not exists (select ''x'' from '-
        ||r.owner||'.'||r.table_name-
        ||' where '||rc.column_name||' = a.'||cc.column_name||')'
from    dba_constraints c,
        dba_constraints r,
        dba_cons_columns cc,
        dba_cons_columns rc
where   c.constraint_type = 'R'
and     c.owner not in ('SYS','SYSTEM')
and     c.r_owner = r.owner
and     c.owner = cc.owner
and     r.owner = rc.owner
and     c.constraint_name = cc.constraint_name
and     r.constraint_name = rc.constraint_name
and     c.r_constraint_name = r.constraint_name
and     cc.position = rc.position
and     c.owner = '&table_owner'
and     c.table_name = '&table_name'
and     c.constraint_name = '&constraint_name'
/

Create a Scrolling News Ticker in JavaScript

With HTML marquee tag you can get scrolling effect. But in order to gain more control in your text you need custom JavaScript code for your news ticker. There are many online scripts available for news ticker. Among them I am using script from http://www.mioplanet.com/rsc/newsticker_javascript.htm.

Here is the JavaScript file. Let's name it ticker.js
TICKER_CONTENT = document.getElementById("TICKER").innerHTML;
 
TICKER_RIGHTTOLEFT = false;
TICKER_SPEED = 2;
TICKER_STYLE = "font-family:Arial; font-size:12px; color:#444444";
TICKER_PAUSED = false;

ticker_start();

function ticker_start() {
 var tickerSupported = false;
 TICKER_WIDTH = document.getElementById("TICKER").style.width;
 var img = "<img src=ticker_space.gif width="+TICKER_WIDTH+" height=0>";

 // Firefox
 if (navigator.userAgent.indexOf("Firefox")!=-1 || navigator.userAgent.indexOf("Safari")!=-1) {
  document.getElementById("TICKER").innerHTML = "<TABLE  cellspacing='0' cellpadding='0' width='100%'><TR><TD nowrap='nowrap'>"+img+"<SPAN style='"+TICKER_STYLE+"' ID='TICKER_BODY' width='100%'> </SPAN>"+img+"</TD></TR></TABLE>";
  tickerSupported = true;
 }
 // IE
 if (navigator.userAgent.indexOf("MSIE")!=-1 && navigator.userAgent.indexOf("Opera")==-1) {
  document.getElementById("TICKER").innerHTML = "<DIV nowrap='nowrap' style='width:100%;'>"+img+"<SPAN style='"+TICKER_STYLE+"' ID='TICKER_BODY' width='100%'></SPAN>"+img+"</DIV>";
  tickerSupported = true;
 }
 if(!tickerSupported) document.getElementById("TICKER").outerHTML = ""; else {
  document.getElementById("TICKER").scrollLeft = TICKER_RIGHTTOLEFT ? document.getElementById("TICKER").scrollWidth - document.getElementById("TICKER").offsetWidth : 0;
  document.getElementById("TICKER_BODY").innerHTML = TICKER_CONTENT;
  document.getElementById("TICKER").style.display="block";
  TICKER_tick();
 }
}

function TICKER_tick() {
 if(!TICKER_PAUSED) document.getElementById("TICKER").scrollLeft += TICKER_SPEED * (TICKER_RIGHTTOLEFT ? -1 : 1);
 if(TICKER_RIGHTTOLEFT && document.getElementById("TICKER").scrollLeft <= 0) document.getElementById("TICKER").scrollLeft = document.getElementById("TICKER").scrollWidth - document.getElementById("TICKER").offsetWidth;
 if(!TICKER_RIGHTTOLEFT && document.getElementById("TICKER").scrollLeft >= document.getElementById("TICKER").scrollWidth - document.getElementById("TICKER").offsetWidth) document.getElementById("TICKER").scrollLeft = 0;
 window.setTimeout("TICKER_tick()", 30);
}


Now just integrating this simple HTML code will have scrolling effect.
<DIV ID="TICKER" STYLE="overflow:hidden; width:520px"  onmouseover="TICKER_PAUSED=true" onmouseout="TICKER_PAUSED=false">
  My First Ticker!
</DIV>
<script type="text/javascript" src="ticker.js" language="javascript"></script>

Let's know some about parameters:
1) TICKER_RIGHTTOLEFT: Set to true if the text is in Arabic, Hebrew or other right-to-left writing language.

2) TICKER_SPEED: This is scrolling speed. Default value is 2. Increase or decrease it based on your choice.

3) TICKER_STYLE: Set the default style for the scrolling text. Change font-size, font-family and color on ticker text.

4) TICKER_PAUSED: When this variable is set to true, the scrolling ticker is paused. This value can be changed at runtime, for example when the mouse is over the ticker.

Thursday, February 17, 2011

How to change body and header background color in Dolphin

If you ever worked with Dolphin 7 you see even you use firebug or Google Chrome inspect element it is using some temporary cached css. You can change the attributes and their value from cache but changing value from cache does not change the value of your desired header and body color as well as their background. You might waste your time to change the value of landing page header, background color and image.

Change background color and background Image of Body
To change the color and background image of homepage and others pages just go to,
/templates/base/css directory and open the common.css file.
You will see an entry like below.

body {
font-family:Verdana,Arial;
font-size:11px;
color:#333333;
background-color:#589CBC;
margin:0px;
padding:0 0 50px 0;
}

Now change this body to
body {
font-family:Verdana,Arial;
font-size:11px;
color:#white;
background-image:url(../images/bg.gif);
margin:0px;
padding:0 0 50px 0;
}

in order to change the landing and common pages background color to white.
Also change the landing and common pages background image to bg.gif.
Note that you must upload image in the location of /templates/base/image.

After you do the above step you must remove the cache and cache_public folder in order to see the changes which you can found from main hosting directory.

Change header color and background Image of header
To change the color and background image of header and others common pages header just go to,
/templates/base/css directory and open the general.css file. Search for div.sys_main_logo entry.
You will see the value like below.
div.sys_main_logo {
position: relative;
z-index: 56;
background-color: #f4f4f4;
}

Change the value like below
div.sys_main_logo {
background-color: silver;
background-image: url("../images/banner.gif");
background-position: right top;
background-repeat: no-repeat;
position: relative;
z-index: 56;
}

to make background color to silver.
Background image to ../images/banner.gif
Backgound image position to right top.
No backgound repeat.

Note that you must upload image in the location of /templates/base/image.

After you do the above step you must remove the cache and cache_public folder in order to see the changes which you can found from main hosting directory.

Tuesday, February 15, 2011

Oracle Data Warehouse Quiz and Exercise

1. (TCO 3) Which of the following is NOT a technique used to optimize data warehouse design? (Points: 3)
         
         
         
         


2. (TCO 3) In contrast to the traditional DSS tools, data mining can _____________ (Points: 3)
         
         
         
         


3. (TCO 3) During the data ____ phase of data mining, common characteristics or patterns are identified. (Points: 3)
         
         
         
         


4. (TCO 3) The location of each data value in the ______ is a function of the x, y, and z axes in a tree-dimensional space. (Points: 3)
         
         
         
         


5. (TCO 3) ____ is defined as an advanced data analysis environment that supports decision making, business modeling, and an operation's researching activities. (Points: 3)
         
         
         
         


6. (TCO 4) The business intelligence technique, ___________, provides an in-depth description of other company's background, finances, products, markets, facilities, personnel, and strategies. (Points: 3)
         
         
         
         


7.  (Points: 12)

How to add a banner to your dolphin site

With dolphin administration panel you can add a banner to a site's Top or Left or Right or in the Bottom section. You can simply need to follow following steps to make it work.

Step 01: Login to your dolphin administration panel. It is usually http://dolphin_installation_path/administration.

Step 02: On the left side navigation menu click on Tools arrow key.

Step 03: From the drop down menu option click on Banners.

Step 04: Manage banners box will appear. Enter Title and url there. Click on the checkbox next to active to make your banner active.
Add Banner Text (add the html code as you want.)

Step 05: Add a check in the box where you would like the banner to display. Can be top, right, bottom, left and then click submit. If you want to edit then you must click edit option in the manage banners.

Munmun with her baby girl at Mirpur on 28th January 2011

On 28th January 2011, Munmun came with her baby girl in our rented flat before we shift to Uttara-14. I took some shot of her as well as her baby which I like to post in my blog.









Aabasaa Arju at the age of 8 months

In this post you will see eight months old Aabasaa Arju. All white colored dress photo was taken on 1st January 26, 2011 while we were at Mirpur. Rest photo was taken at 30th January and 1st February 2011.















Monday, February 14, 2011

Business Intelligence - Database Warehouse Labs


Lab 6 of 6: Business Intelligence (50 Points)
Your assignment is due by the beginning of the next class meeting. Submit your assignment to theDropbox located on the silver tab at the top of this page. For instructions on how to use the Dropbox , please click here.

L A B   O V E R V I E W
Scenario/Summary
As part of creating a business intelligence strategy for Ann's company, we will:
Identify internal data to be warehoused
  • Identify external data to be warehoused

  • Determine how to extract the data

  • Consider how the extracted data will be analyzed

  • Provide a recommendation to Ann's company

  • Deliverables
    Submit a completed LAB6_Report.doc, including copy/pastes of your SQL and results from SQL*Plus, to DropBox for Week 6.
    L A B   S T E P S
    STEP 1: Identify internal data to warehouse (5 points)
    Consider the internal corporate data that is available to Ann and her company.
    1. List the attributes, by table, in Ann's database that should be warehoused.
    2. List the attributes, by table, in the corporate database that should be warehoused.
    3. List other internal data values that should be warehoused, so Ann's organization can locate the data or begin tracking it.
    4. Explain why this data might be of interest.
    Write your response in the LAB 6 Report document.
    STEP 2: Identify external data to warehouse (5 points)
    Consider the external business data that might be of interest to Ann and her company.
    1. List categories of business data that might be of interest (i.e. what competitors are doing).
    2. Identify sources where this data could potentially be obtained.
    3. Explain why this data might be of interest.
    Write your response in the LAB 6 Report document.
    STEP 3: Extract the data for analysis (15 points)
    Analyzing previous class attendance can help Ann forecast future class attendance. She and her organization can use this information to determine which classes need to be held more or less frequently, or even discontinued.
    1. Start SQL*Plus 
    2. Write the SQL statement(s) to select location, course, date, and attendance data from Ann's database.
    3. Execute the SQL.
    4. Save the resulting data in an Excel worksheet.
    Type your SQL statements into the LAB 6 Report document.
    STEP 4: Analyze the data (10 points)
    Use a three-dimensional view to analyze the attendance data (Hint: see section 12.5 in Rob & Coronel).
    1. Identify the facts, dimensions, and attributes extracted in Step 3.
    2. Using the Excel worksheet created in Step 3, create pivot tables to represent the three dimensions.
    3. Determine which dimension will be of interest to which department within Ann's organization. Explain.
    Write your response in the LAB 6 Report document.
    STEP 5: Provide a recommendation (15 points)
    Based on the Week 6 iLab and the lecture, write a recommendation on how Ann should use OODBMS functionality in Oracle.
    • Consider that the audience will be Ann and her peer business managers, as well as technical staff from DBA to CIO. 
    • Identify the business problem to be addressed (i.e. business intelligence strategy).
    • Present the recommended solution.
    • Briefly address benefits and risks associated with the solution.
    • Use correct spelling and proper grammar.
    Write your recommendation in the LAB 6 Report document.
    Your assignment is due by the beginning of the next class meeting