Certain rules and guidelines apply when you override a lookup query.
Use the following guidelines:
You can override the lookup SQL query for relational lookups.
Enter the entire SELECT statement using the syntax that is required by the database.
Enclose all database reserved words in quotes.
Include all lookup and return fields in the SELECT statement.
If you add or subtract fields in the SELECT statement, the
mapping
task fails.
Use an alias for each column in the query.
If you do not use column aliases, the mapping task fails with the following error:
Failed to initialize transformation [<Lookup Transformation Name>]
To override the ORDER BY clause, append "
--
" at the end of the query.
The
mapping
task generates an ORDER BY clause, even when you enter one in the override. Therefore, you must enter two dashes (
--
) at the end of the query to suppress the generated ORDER BY clause.
If the ORDER BY clause contains multiple columns, enter the columns in the same order as the fields in the lookup condition.
If the
mapping
task uses SQL ELT optimization or is based on a mapping in SQL ELT mode, you can't override the ORDER BY clause or suppress the generated ORDER BY clause with comment notation.
If multiple Lookup transformations share a lookup cache, use the same lookup SQL override for each Lookup transformation.
When you configure a Lookup transformation that returns all rows, the
mapping
task builds the lookup cache with sorted keys. When the transformation retrieves all rows in a lookup, the
mapping
task builds the data cache with the keys in sorted order. The
mapping
task cannot retrieve all the rows from the cache if the rows are not sorted. If the data is not sorted on the keys, you might get unexpected results.
You cannot include parameters in the lookup SQL override.
If you configure a lookup SQL override and a lookup source filter in the same transformation, the