Using DEF Lines to Read from an ODBC Datasource

This example illustrates how the two forms of the DEF lines can be used to read from an ODBC database source, which is named rogers.

READER_TYPE DB2
DB2_DATASET      sampledb
DB2_USER_NAME     <userName>   
DB2_PASSWORD      <password>   

# Form 1 of the DEF line is used like this -- it reads just
# the two fields we list and applies the where clause

DB2_DEF supplier \
    db2_where_clause "id < 5"	\
    ID  integer \
    CITY char(50) 

# Form 2 of the DEF line is used like this -- we let SQL 
# figure out what fields we want and do a complex join 
# involving 3 tables. The FME features will have whatever 
# fields are relevant. The "feature type" as far as 
# FME is concerned is whatever was put on the DEF line.
# In this case "complex" is the feature type, even though no 
# table named "complex" is present in the database.

DB2_DEF complex \
    db2_sql "SELECT CUSTOMER.NAME, CUSTOMER.ID, 
   VIDEOS.ID, VIDEOS.TITLE FROM RENTALS, CUSTOMER,
   VIDEOS WHERE RENTALS.customerID = CUSTOMER.ID AND
   VIDEOS.ID = RENTALS.videoID AND CUSTOMER.ID = 1" # Finally, define the NULL writer as the output -- this will # log everything we read to the log file for inspection. WRITER_TYPE NULL NULL_DATASET null FACTORY_DEF * SamplingFactory \ INPUT FEATURE_TYPE * @Log()