Developer Tool Guide > Flat File Data Objects > Update Columns at Run Time
  

Update Columns at Run Time

You can configure a flat file data object to accommodate changes to source metadata at run time. The Data Integration Service can read data from a flat file where the number or order of the columns is different from that of the columns in the flat file physical data object.
For example, you have a mapping whose source is provided by another department. The department that provides the source cannot guarantee the order of columns in the source file. Sometimes, the department might change the columns in the file or contain additional columns. You can configure the flat file data object to accept changes in the source metadata at run time.
You can generate the run-time column names automatically from any row in the source, from the flat file header, or from the control file.
You can use input rules to project the run-time columns from the Read transformation based on the flat file data object to the next transformation in the mapping.
You can configure the Read transformation data object property to select At runtime, get data object columns from the data source on the Data Object tab. After you configure the property, the options in the flat file data object determine how the Data Integration Service processes the data.

Generate Run-time Column Names Automatically

The Data Integration Service can update the column metadata for the flat file automatically based on the column position.
The Data Integration Service dynamically updates the column metadata for the flat file based on the row that you specify to start the import in the format properties of the flat file. The default data type, precision, and scale is used for the column metadata for the run-time columns without changing the column position.
To generate column names automatically at run time, select Automatically (Field1, Field 2...) for the Generate Run-time Column Names property in the Advanced properties of the flat file data object. You must also configure the Read transformation to get the column metadata at run time.
For example, you want to configure a flat file data object to accept changes at run time. The data in the flat file determines the column metadata based on the column position. You have defined a flat file data object with the columns Dept, Name, Place. You want the Data Integration Service to dynamically construct the column metadata for the flat file at run time.
The input file contains the following information:
HR,Bob,Chicago,US,87675
Finance,Mary,California,US,65437,t567,4200
In the Format properties, you configured the flat file data object to start the import of data from line 1. Since there are five columns in the first row, the Data Integration Service processes the flat file data object with five columns. The Data Integration Service creates additional run-time columns in the flat file data object with unique names based on position, Field4 and Field5. The Data Integration Service does not process the additional columns in the second row.
When you add a flat file data object to a mapping, configure the Read transformation to get column metadata at run time. At run time, the Data Integration Service constructs the flat file data object and process the rows in the flat file with the following values:
Dept Name Place Field4 Field5
HR Bob Chicago US 87675
Finance Mary California US 65437

Generate Run-time Column Names From Data File Header

The Data Integration Service can use a header row to determine the column metadata. The first row of the flat file is the header.
The default data type, precision, and scale is used for the column metadata for the run-time columns and you can change the column position at run time.
To generate column names from a data file header at run-time, select From data file header (first line) for the Generate Run-time Column Names property in the Advanced properties of the flat file data object. You must also configure the Read transformation to get the column metadata at run time.
For example, you want to configure a flat file data object to accept changes at run time. The data in the flat file determines the column metadata based on the data file header.
You have defined a flat file data object with the columns Name,Age,Dept. You can configure the flat file data object advanced property to generate column names at run time from a data file header.
The data flat file contains the following information:
Dept Name Place Country Phone_No.
HR Bob Chicago US 87675
Finance Mary California US 65437 t567 4200
When you add a flat file data object to a mapping, configure the Read transformation to get column metadata at run time. During run time, the Data Integration Service generates the flat file data object with the following columns: Dept, Name, Place, Country and Phone_No. Since Age column is not present in the flat file header row, the flat file data object constructed at run time does not have the Age column.
The Data Integration Service propagates the run-time columns, such as Country and Phone Number to the downstream transformation based on the mapping rules.