martedì 21 maggio 2013

ORA-02292: integrity constraint (.) violated - child record

I was writing an ODI procedure from creating a static dimension from scratch. The procedure looked like this:

begin
DELETE FROM <DIM_TABLE>;
INSERT INTO <DIM_TABLE> VALUES (0,1,etc.);

COMMIT;
end


When I run it, I got the following error:

ORA-02292: integrity constraint (<OWNER>.<FK_CONSTRAINT>) violated - child record

The error means that I was trying to delete values that were used in a column that had a foreign key constraint on it.
To overcome this issue, without deleting any value in the referencing table, you first have to disable the constraint and then enable it again once you have finished populating the table.
So the procedure will look like this:


begin
execute immediate 'ALTER TABLE <DIM_TABLE> DISABLE CONSTRAINT <OWNER>.<FK_CONSTRAINT>';
DELETE FROM <DIM_TABLE>;
INSERT INTO <DIM_TABLE> VALUES (0,1,etc.);
COMMIT; 

execute immediate 'ALTER TABLE <DIM_TABLE> ENABLE CONSTRAINT <OWNER>.<FK_CONSTRAINT>';
end

lunedì 6 maggio 2013

Tip: How to specify Service Name in JDBC Connection

I needed to specify a new Oracle Database Connection in ODI. I have always used SIDs to configure JDBC connections.

jdbc:oracle:thin:@<hostname>:<port>:SID

Changing the SID for Service Name requires a minor syntax change. You have to replace the semicolon with a slash:


jdbc:oracle:thin:@<hostname>:<port>/<Service Name>

lunedì 22 aprile 2013

Tip: Oracle Data Modeler How to display just object names in a diagram

You may need to put your logical or physical diagram in a PowerPoint presentation, but it is quite unpractical showing all columns and details of a table. If you just want to show the Object Name, you have to go to View -> Details -> Only Names.


Then, you can give a better look to your diagram by customizing the look and feel and the best thing is that you can always go back to the full view.

martedì 2 aprile 2013

Tip: Solve ORA-14402

Recently I have partitioned a fact table and today I had to perform the weekly load.
I got into the error:

ORA-14402: updating partition key column would cause a partition change


This error was being raised every time I tried to update the partition field (a date) in a record. To overcome this issue just execute the following:


ALTER TABLE <my_table> ENABLE ROW MOVEMENT;

Tip: Scheduling OWB jobs using SQLPlus

Scheduling jobs in OWB 11g using the Calendar feature is possible only if you have bought the Data Integrator Enterprise Edition, which is not the case of the project I am currently working on.

Error you get when you try to create a new Calendar Module in OWB 11g without Data Integrator EE license

You can still schedule jobs by using a SQLPlus script which can then be called in a .bat or Shell script and scheduled using Windows Scheduler or Crontab in Unix.
In OWB 11g, we can find a SQL script ready to use in [OWBHOME]\owb\rtp\sql. The script you need is called: sqlplus_exec_template.sql
The script can be executed only by a Workspace Owner or a Workspace user with Execute privileges.
The script uses the following parameters:
  • WORKSPACE 
  • Workspace in which the job is to run: e.g. MY_WORKSPACE Make sure you specify the right Workspace Name. You can check it by executing:  

    SELECT * FROM ALL_IV_WORKSPACES
  • LOCATION_NAME 
  • Physical Name of the Location to which this task was deployed: e.g. MY_WAREHOUSE  
  • TASK_TYPE   
    • PLSQLMAP - OWB PL/SQL Mapping
    • SQLLOADERCONTROLFILE - OWB SQL*Loader Mapping
    • PROCESSFLOW - OWB ProcessFlow
    • ABAPFILE - OWB SAP Mapping
    • DATAAUDITOR - OWB DataAuditor Mapping
    • SCHEDULEDJOB - OWB Scheduled Job
    • CTMAPPING  - OWB Template Mapping
  • TASK_NAME
  • Physical Name of the Deployed Object.e.g. MY_MAPPING. Make sure you specify the TASK_NAME in the following format: [PARENT_TASK]/TASK_NAME
  • SYSTEM_PARAMS { , | (name = value [, name = value]...)}
  • CUSTOM_PARAMS { , | (name = value [, name = value]...)}
The following example shows how to call the DIM_ALL workflow under DIM_FACT workflow package deployed in WFS_LOCATION location in MYWKS workspace.

SQL> @sqlplus_exec_template.sql MYWKS WFS_LOCATION PROCESSFLOW "DIM_FACT
/DIM_ALL" "," ","


The script calls functions from the OWBSYS.wb_rt_script_util package so you may need to grant the right privilege to the OWB User.

    mercoledì 20 marzo 2013

    Tip: DATE and DATETIME in OBIEE

    I must admit that I am new to the OBIEE world and I really wish I can help people that are starting with this Oracle product to save some precious time when dealing with Calendar dimensions.
    I have created a Calendar dimension in my database with a field "DIA" to be DATE. This dimension is meant to replace one that was already in place, same content, but more fields. I have imported the table in the physical layer, mapped it to the logical layer, but when I run the dashboard I kept on seeing date fields with DD/MM/YYYY hh:mm in the calendar prompts.
    I spent quite a lot of time (call me dumb!) to find out that the answer was as simple as replacing the DATETIME field with DATE.


    venerdì 15 marzo 2013

    Tip: Reverse Engineering in Oracle Data Modeler

    I am currently building a Data Warehouse using OWB as integration tool. I have almost finished and now comes what I like the less about my job... documentation!
    During the development process, you usually create a number of staging tables. Oracle Data Modeler allows you to import tables from a schema. This way it is much easier writing down your documentation and you also have a visual presentation ready to use.
    Let's go through the reverse engineering process:
    1) Go to File -> Import -> Data Dictionary


    2) Add a new connection if you haven't set up any yet

    3) Select your Schema/Database


    
    Personally I find the filter option pretty useful for retrieving quickly the Schema you are looking for.

    4) Select the objects you want to import


    5) Click on Finish

    If everything goes ok, you have your Model imported in Oracle Data Modeler and you can export images of your diagrams or generate your DDL code to attach to your documentation.