Introduction to the Substitution API

2 Introduction to the Substitution API 2-1 2 Introduction to the Substitution API This chapter provides an introduction to the Oracle Data Integrator Substitution API using examples. This chapter includes the following sections: ■ Section 2.1, Introduction to the Substitution API ■ Section 2.2, Using Substitution Methods ■ Section 2.3, Using Substitution Methods in Actions ■ Section 2.4, Working with Object Names ■ Section 2.5, Working with Lists of Tables, Columns and Expressions ■ Section 2.6, Generating the Source Select Statement ■ Section 2.7, Working with Datasets ■ Section 2.8, Obtaining Other Information with the API ■ Section 2.9, Advanced Techniques for Code Generation

2.1 Introduction to the Substitution API

KMs are written as templates by using the Oracle Data Integrator substitution API. The API methods are java methods that return a string value. They all belong to a single object instance named odiRef. The same method may return different values depending on the type of KM that invokes it. Thats why they are classified by type of KM. To understand how this API works, the following example illustrates how you would write a create table statement in a KM and what it would generate depending on the datastores it would deal with: The following code is entered in a KM: CREATE TABLE =odiRef.getTableL, INT_NAME, A =odiRef.getColList, \t[COL_NAME] [DEST_CRE_DT], ,\n, , The generated code for the PRODUCT table is: CREATE TABLE db_staging.I_PRODUCT Note: The substitution API methods are listed in Appendix A, Substitution API Reference . 2-2 Oracle® Fusion Middleware Knowledge Module Developer’s Guide for Oracle Data Integrator PRODUCT_ID numeric10, PRODUCT_NAME varchar250, FAMILY_ID numeric4, SKU varchar13, LAST_DATE timestamp The generated code for the CUSTOMER table is: CREATE TABLE db_staging.I_CUSTOMER CUST_ID numeric10, CUST_NAME varchar250, ADDRESS varchar250, CITY varchar50, ZIP_CODE varchar12, COUNTRY_ID varchar3 As you can see, once executed with appropriate metadata, the KM has generated a different code for the product and customer tables. The following topics cover some of the main substitution APIs and their use within KMs. Note that for better readability the tags and as well as the odiRef object reference are omitted in the examples.

2.2 Using Substitution Methods