Dylan's BI Study Notes

My notes about Business Intelligence, Data Warehousing, OLAP, and Master Data Management

ODI SDK – Update Variable

Here I tried to update an existing variable.  Updating a single variable variable is easy and you probably do not need to use SDK.

We decided to not keep history value and we have a lot of variables.  Update variables property centrally using the ODI SDK is handy.

import oracle.odi.core.persistence.transaction.ITransactionDefinition;
import oracle.odi.core.persistence.transaction.support.DefaultTransactionDefinition;
import oracle.odi.core.persistence.transaction.ITransactionManager;
import oracle.odi.core.persistence.transaction.ITransactionStatus;
import oracle.odi.core.persistence.IOdiEntityManager;
import oracle.odi.domain.project.OdiProject;
import oracle.odi.domain.project.OdiVariable;
import oracle.odi.domain.project.finder.IOdiProjectFinder;
import oracle.odi.domain.project.finder.IOdiVariableFinder;

ITransactionDefinition txnDef = new DefaultTransactionDefinition();

ITransactionManager tm = odiInstance.getTransactionManager();
ITransactionStatus txnStatus = tm.getTransaction(txnDef);

IOdiEntityManager mgr = odiInstance.getTransactionalEntityManager();

OdiProject proj = ((IOdiProjectFinder) mgr.getFinder(OdiProject.class)).findByCode("NEW_PROJECT");
OdiVariable myVariable = ((IOdiVariableFinder) mgr.getFinder(OdiVariable.class)).findByName("ETL_PROC_WID", proj.getCode());

myVariable.setValuePersistence(OdiVariable.ValuePersistence.HISTORIZE);

odiInstance.getTransactionalEntityManager().persist(proj);

tm.commit(txnStatus);

I use the setValuePersistence this time. setAction is actually deprecated.

Advertisements

One Response to “ODI SDK – Update Variable”

  1. […] I tried to use ODI SDK to create a project, create a folder, create a subfolder, create a short to an interface, create a variable, and update a variable. […]

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s