Showing posts with label ODI12c. Show all posts
Showing posts with label ODI12c. Show all posts

Wednesday, 18 October 2017

ODI 12c Loading multiple files in a directory to Target table using looping concept.

Hi Guys,

I have a requirement to load all the csv files available in a folder to the target table. The file structure will be same but the name will be vary for each file. So i used variable and looping concept in ODI to achieve this requirement.

Steps followed.
1) list out the names of all the .csv files available in a directory to a temporary file.
----Command----

ls *.csv > Directory/Text_.txt

2) Separate the names into one by one.
---Command----

awk 'sub("$","\r")' Directory/Text_.txt > DirectoryALL_FILE_NAMES.txt

3)Write the file names into a Target table the structure of the target table can be.We can use an ODI interface to

CREATE TABLE ALL_FILE_NAMES
(
ROW_NUMBER INT,
FILE_NAME VARCHAR(50),
LOAD_STATUS VARCHAR(5),
LOAD_DATE DATE)
;

Row_Number: Sequence
File_Nmae: Can directly map the name from the file in ODI mapping.
Load_Status:Stamp 'N' as default.
Load_Date: Sysdate.

4) Create a variable for taking the file count. Select the count of files having LOAD_STATUS equals 'N'

5) Create an Evaluate variable
This variable can be used for looping through the package. In the evaluate condition we can give '>=1' so till the file count equals 0 the loop will be repeated.

6) Create a global variable for picking the file name dynamically.

Eg:
SELECT max(FILE_NAME) FROM ALL_FILE_NAMES
WHERE LOAD_STATUS='N'
group by FILE_NAME
ORDER BY 1


7) Create the interface for loading the data. The above created variable can be used as a file name for this interface.

Resource_Name:#GLOBAL.V_FILE_NAME

8) Create an ODI procedure for updating the file name.This will update the loaded file status to Y and this file will not be picked for next load.

UPDATE ALL_FILE_NAMES SET LOAD_STATUS='Y' WHERE FILE_NAME in (SELECT FILE_NAME FROM ALL_FILE_NAMES
WHERE LOAD_STATUS='N'
and FILE_NAME=#GLOBAL.V_FILE_NAME

9)Take the file count again. This time you will get the updated file count and if that is greater than 0 the loop will be repeated.

10) Refer the screen shot below so you will get a better understanding about the loop process.







Tuesday, 19 September 2017

ODI error ORA-02292: integrity constraint (ODI_REPO.FK_MAP_PROP_1) violated - child record found

Error From ODI Error log.

java.lang.RuntimeException: java.lang.RuntimeException: java.lang.Exception: ODI-20088: Error while generating the scenario
.
Caused by: java.lang.RuntimeException: java.lang.Exception: ODI-20088: Error while generating the scenario
.
Caused by: java.lang.Exception: ODI-20088: Error while generating the scenario
.
Caused by: oracle.odi.core.repository.UncategorizedRepositoryAccessException: ODI-10182: Uncategorized exception during repository access.
ODI-10143: Error while accessing the ODI repository.
ORA-02292: integrity constraint (ODI_REPO.FK_MAP_PROP_1) violated - child record found
.
Caused by: oracle.odi.core.repository.RepositoryIntegrityViolationException: ODI-10143: Error while accessing the ODI repository.
ORA-02292: integrity constraint (ODI_REPO.FK_MAP_PROP_1) violated - child record found
.
Caused by: java.sql.SQLIntegrityConstraintViolationException: ORA-02292: integrity constraint (ODI_REPO.FK_MAP_PROP_1) violated - child record found


Cause:

Actually i tried to find out if there is any mistakes in the mapping but it is perfectly fine and no other issues.The issue is that we cannot generate the scenario for that.
The reason is some how the code for the mapping is corrupted.

Solution:

I found the solution from the Oracle blog, just updating that here.

The solution is to upgrade the ODI environment to the latest version of ODI 12.2.1.2.6.

There is a workaround involving an export/import of the mapping that can be used until the environment can be patched.

Export the problem mapping.
Open the mapping xml export file for edit.

Locate the lines containing field name IOwnerExecUnit with a number as a value.

For example:
<Field name="IOwnerExecUnit" type="com.sunopsis.sql.DbInt"><![CDATA[40275]]></Field>

You have the option to remove the line completely, or change the line to have a null value.
For example:
<Field name="IOwnerExecUnit" type="com.sunopsis.sql.DbInt"><![CDATA[null]]></Field>

Import this file back into ODI. You should be able to successfully compile it into a scenario.

After doing this step i am able to create the scenario and run it.

Hope this will help you also !.