Saturday, February 16, 2019

How to trigger scenario from jython code in ODI?

Triggering Scenario from Jython code:

In this example I am consider all the scenario's whose name starts with SCN_INT.
Path provided here is where standalone agent is installed in my machine. You have to specify according to your machine.

Note: If it is windows make sure that your using '\\' instead of '\' in the path
Oracle won't recommends using directly metadata tables in your script. It is just for your information.


import java.util.Date as Date
from com.ziclix.python.sql import zxJDBC
import java.sql as sql
import os
import thread

def ins(path):
os.chdir("D:\\SoftwareInstalled\\Oracle\\Middleware\\Oracle_ODI\\oracledi\\agent\\bin")
list=os.system(path)

URL = "<%=odiRef.getInfo("SRC_JAVA_URL")%>"
userName = "<%=odiRef.getInfo("SRC_USER_NAME")%>"
password = "<%=odiRef.getInfo("SRC_PASS")%>"
Driver = "oracle.jdbc.driver.OracleDriver"

myCon = sql.DriverManager.getConnection(URL,userName,password)
myStmt = myCon.createStatement()

sqlQry = "SELECT SCEN_NAME,SCEN_VERSION FROM DEV_ODI_REPO.SNP_SCEN WHERE SCEN_NAME LIKE 'SCN_INT%'"

jobRs = myStmt.executeQuery(sqlQry)

while (jobRs.next()):
path = 'startscen.bat '+jobRs.getString("SCEN_NAME")+' '+jobRs.getString("SCEN_VERSION")+' GLOBAL'
thread.start_new_thread(ins,(path,))
myCon.close()











No comments:

Post a Comment