이벤트 스크립트 샘플

다음 샘플 이벤트 스크립트는 데이터 로드 실행 중 table_xyz 테이블을 업데이트합니다.

#-----------------------------------------------------------------------------
# Sample to update table_xyz table during data load rule execution
#-----------------------------------------------------------------------------
query = "UPDATE table_xyz SET accountx = 'SCRIPT_' || account WHERE loadid = ? and accountx is NULL"
params = [ fdmContext["LOADID"] ]
print fdmAPI.executeDML(query, params, False)
fdmAPI.commitTransaction()
#-----------------------------------------------------------------------------
# Sample to import data from a custom SQL source and upload into FDMEE 
# open interface table. This script should be called in BefImport Event. 
# This is alternate to the FDMEE integration import script.
#-----------------------------------------------------------------------------
import java.sql as sql
batchName = "Batch_" + str(fdmContext["LOCNAME"])
insertStmt = """
INSERT INTO AIF_OPEN_INTERFACE (
   BATCH_NAME
  ,COL01
  ,COL02
  ,AMOUNT
  ,DESC1
) VALUES (
?
,?
,?
,?
,?
) 
"""
sourceConn = sql.DriverManager.getConnection("jdbcUrl", "user", "password");
# Limiting number of rows to 5 during the test runs.
selectStmt = "SELECT * FROM orders WHERE rownum < 6"
stmt = sourceConn.prepareStatement(selectStmt)
stmtRS = stmt.executeQuery()
while(stmtRS.next()):
  params = [ batchName, stmtRS.getBigDecimal("Customer_Id"), 
             stmtRS.getString("Ship_Country"), 
             stmtRS.getBigDecimal("Freight"), stmtRS.getString("Ship_Name") ]
  fdmAPI.executeDML(insertStmt, params, False)
fdmAPI.commitTransaction()
stmtRS.close()
stmt.close()
sourceConn.close()
#------------------------------------------------------------------------------
# Sample to send email messages using Jython SMTP library
-------------------------------------------------------------------------------
import smtplib
sender = "from@gmail.com"
receivers = "to@gmail.com"
message = """ This is a test e-mail message.
              This is a test e-mail message.  """  
try:
  smtpServer = smtplib.SMTP('smtp.gmail.com:587')
  smtpServer.starttls()
  smtpServer.login("user", "password")  
  smtpServer.sendmail(sender, receivers, message)
  print "Successfully sent email"
  smtpServer.quit() 
except Exception, e:
  print "Error: unable to send email: " + str(e)  

주:

다음 링크에서 Jython 예외 목록 및 스크립트에서 예외를 트랩할 때 사용할 구문을 설명하는 온라인 Jython 설명서를 참조하십시오. Jython에서 예외 처리 메커니즘을 사용하는 방법에 대한 자세한 내용은 예외 처리 및 디버깅을 참조하십시오.

이 설명은 모든 스크립트 유형에 적용됩니다.