Dylan's BI Study Notes

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

ODI SDK – Create Variable

ODI variables are used to hold the parameters that will be passed to interfaces.  There is really not much need to create variables using a SDK.

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 = new OdiVariable(proj,"ETL_PROC_WID");
myVariable.setDataType(OdiVariable.DataType.SHORT_TEXT);
myVariable.setAction(OdiVariable.Action.NON_PERSISTANT);
myVariable.setDefaultValue("999");
myVariable.setDescription("ETL Run ID");

odiInstance.getTransactionalEntityManager().persist(proj);

tm.commit(txnStatus);

One Response to “ODI SDK – Create Variable”

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

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