Oracle

How to Raise the Custom Exception in ODI

shutterstock_116299585

This post will explain the process to raise the custom exception in ODI.

Process:

  • Create a variable to store the custom error message
  • Create a procedure to read the error message from the variable and raise the exception.
  • Create a package to set the value in the custom error variable and execute the raise exception procedure.

Steps:

Create a new variable to store the custom error message:

1

We don’t need to select a schema or refreshing query, as this variable value will be set in the Package.

Oracle - Guide to Oracle Cloud: 5 Steps to Ensure a Successful Move to the Cloud
Guide to Oracle Cloud: 5 Steps to Ensure a Successful Move to the Cloud

Explore key considerations, integrating the cloud with legacy applications and challenges of current cloud implementations.

Get the Guide

2

Create the procedure “Raise Custom Exception” and select the Target technology as “Jython”.

3

Go to Details, add step and add the code below in the “Command on Target” tab

<% String errMesg=”>>>>>>> ” +odiRef.getOption(“OBI_ERROR_MESSAGE”) + ” <<<<<<<<“; %>
<$
// New Class being defined for raising custom exceptions
//————————————————————–New Class TableException—————————————-
public class CustomException extends Exception
{
                  String errmesg;
                  public CustomException()
                  {
                    super();             // call superclass constructor
                    errmesg = “CustomException:Unknown Error Occured”;
                  }
                // Constructor with the error message
                  public CustomException(String err)
                  {
                    super(err);     // call super class constructor
                    errmesg = err;  // save message
                  }
                // public method, callable by exception catcher. It returns the error message.
                  public String getError()
                  {
                    return errmesg;
                  }
}//end of class  CustomException
String mesg=”<%=errMesg%>”;
CustomException custErr=new CustomException(mesg);
throw custErr;
$>

 4

Create a new package ‘Raise Previous Incremental Load Failed Exception’, add ERROR_MESSAGE variable to the package and set the variable value to the required custom error message.

5

Add a raise custom exception package

6

Execute this package. It will pass the value in variable ERROR_MESSAGE to Raise the custom exception procedure, and it throws the exception as below:

7

We can use same variable “ERROR_MESSAGE” and Procedure “Raise Custom Exception” to generate different custom exceptions, however, we need to create a separate package for each custom error message.

About the Author

10 years of experience doing analysis, design, development and implementation of Oracle Business Intelligence applications and ETL solutions using Informatica, DAC, ODI. Worked extensively on Oracle BIAPPS Implementations, SQL querying and Stored Procedures using PL/SQL. Worked on Functional Areas - HR, Finance, Service and Marketing Analytics, Procurement and Spend Analytics, Supply Chain and Order Management Analytics, Enterprise Healthcare Analytics (EHA) and OHADI (Oracle Healthcare Analytics Data Integration)

More from this Author

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to the Weekly Blog Digest:

Sign Up
Categories