Creating EZscript Library
An EZscript library is an artifact that contains reusable functions or subroutines. You can create the following types of EZscript libraries and add them to the map or a process:
• General: Create a custom user-defined file or script snippet. You can use the snippets in Process script steps for initializing variables, writing logs to databases, and other operations. For more information, see
Creating General EZscript Libraries.
• Lookup: Build all user-defined functions in a map. When you launch the EZscript Editor from the target map field within a map, these functions are displayed in th EZscript Editor’s tree structure. For more information, see
Creating EZscript Library Using the Lookup Wizard.
Note: If Lookup is used, a Lookup Library type is created based on the selected Lookup type.
You can also import existing script files into EZscript libraries.
Creating General EZscript Libraries
To create a general EZscript library:
1. Select a DataConnect project and do any of the following:
• Go to File > New > EZscript Library.
• Click the arrow in
and then click
EZscript Library.
• Right-click on the project and then click New > EZscript Library.
The New EZscript Library dialog is displayed.
2. Specify the following:
• Select a file extension - Select ezscript, bas, or rifl to specify the file extension.
• Select a type of EZscript Library - Select General.
3. Click Next.
4. In the EZscript Library Name field, type a name for the EZscript library file.
5. Click Finish.
A new EZscript library file is created and it opens as a separate tab. The file extension is .ezscript, .bas, or .rifl based on your selection in step 2.
For more information about EZscript, see
Scripting.
Creating EZscript Library Using the Lookup Wizard
Lookups are files or tables where each row of data contains a key field and one or more other fields that can be selected as a return value. A simple example is a file or table that has 50 rows of data, each row having two fields, one field that contains a state abbreviation code (such as TX) and the other field containing a state name (such as, Texas). When creating a transformation, if the source data contains state codes but you want the target to contain full state names, you can perform a lookup, that is, pass the state code "key" and the key returns the state name, which is written to the target.
The Lookup Wizard helps you to build scripts as templates, which can be reused. For any map or a process, you can add the lookup script file in the Configuration tab.
Prerequisites:
• You must know the location of the lookup data, whether it is a file or a table.
High-level steps:
1. Connect to the lookup data (file or table).
2. Preview and verify the lookup data fetched from the file or table.
3. Specify the field that must be used for the lookup key and the field(s) that must be returned as a result of the lookup.
4. For each field that is returned, you must provide a default value in case the lookup key cannot be found in the file.
Lookup Types:
The following types of lookup files can be generated using the EZscript Lookup Wizard:
• Flat file lookup - For lookup values that are static and stored in flat files.
• Dynamic SQL lookup - For lookup values that change frequently and are stored in relational databases.
• Incore lookup - For high performance, in-memory lookup.
Creating Flat File Lookup EZscript Libraries
Flat file lookup is a DlmAscii file that has CR/LF record separator, no Field start/end characters, no header row, and so on. The only connector property you can specify is the field separator. For flat file lookups, the first column must be the key.
To create a flat file lookup EZscript library:
1. Select a DataConnect project and do any of the following:
• Go to File > New > EZscript Library.
• Click the arrow in
and then click
EZscript Library.
• Right-click on the project and then click New > EZscript Library.
The New EZscript Library dialog is displayed.
2. Specify the following:
• Select a file extension - Select ezscript, bas, or rifl to specify the file extension.
• Select a type of EZscript Library - Select Lookup.
• Select a lookup type - Select Flat File.
3. Click Next.
The Flat File Lookup dialog is displayed.
4. In Lookup File, click Browse and specify the file that has the data.
5. From File Separator/Delimiter drop-down list, select one of the following:
• ,
• ;
• |
• .
6. Click Next.
The Confirm Lookup Data dialog is displayed.
7. Verify if the data from the file is displayed correctly and click Next.
8. Select the check box for the field that must be returned after performing the lookup and click Next.
9. Confirm the key field and the selected result field and click Next.
10. In the EZscript Library Name field, type a name for the file, and click Next.
Note: The file name must not begin with a number.
The flat file lookup definition summary shows:
• The name and location of the flat file that will be created (with the extension .flatfile.ezscript).
• The list of functions that will be included in the lookup file.
11. Click Finish.
A new EZscript library file in flat file format is created and it opens in the EZscript Editor as separate tab in the EZscript Library perspective. The file extension is .ezscript, .bas, or .rifl based on your selection in step 3.
The new lookup functions are displayed in the editor.
For more information about EZscript, see
Scripting.
Creating a Dynamic SQL Lookup Using the Lookup Wizard
Dynamic SQL lookups can dynamically connect to, or disconnect from, a SQL table to create a lookup. This type of lookup is performed when the data is large and cannot fit in memory. It is slower than the incore lookup, which keeps the lookup data in memory. You must create several functions in the script file (not only a Lookup function) for dynamic SQL lookup. Other functions are to initialize objects and terminate objects.
Note: The list of connectors available for connecting to the lookup data must be filtered to only those that support SQL; because different connectors have different SQL identifiers, you must know the identifier for the connector you want to use.
To create a dynamic SQL lookup EZscript library:
1. Select a DataConnect project and do any of the following:
• Go to File > New > EZscript Library.
• Click the arrow in
and then click
EZscript Library.
• Right-click on the project and then click New > EZscript Library.
The New EZscript Library dialog is displayed.
2. Specify the following:
• Select a file extension - Select ezscript, bas, or rifl to specify the file extension.
• Select a type of EZscript Library - Select Lookup.
• Select a lookup type - Select Dynamic SQL.
3. Click Next.
The Define your Lookup Connection dialog is displayed.
4. Specify the fields to connect to the database, define the lookup, and click Connect.
5. Click Next.
The Confirm Lookup Data dialog displays the data that is fetched from the database based on the criteria specified in step 5.
6. Verify the data and click Next.
The Confirm Connect String dialog displays the string used to connect to the database.
7. Click Next.
The Select a key field and one or more result fields dialog are displayed.
8. Do the following:
• Include - Select the required check box to specify the key fields.
• Key - Click within the cell and select Yes to specify the field that must be used for the lookup key. Else, select No. By default, Yes and No are selected for fields.
• Default Value - Click within the cell and type the default value for the field (if required). For each field that is returned, you must provide a default value in case the lookup key cannot be found in the file.
9. Click Next.
The Confirm key field and result field(s) dialog is displayed.
10. Verify and click Next.
The Define Dynamic SQL DJImport object dialog is displayed.
11. In Enter DJImport Object Name, type the name of the DJImport object.
12. In the EZscript Library Name field, type a name for the EZscript file.
Note: The file name must not begin with a number.
13. Click Finish.
A new EZscript library file in dynamic SQL format is created and it opens as a separate tab. The file extension is .ezscript, .bas, or .rifl based on your selection in step 2.
For more information about EZscript, see
Scripting.
Creating an Incore Lookup Using the Lookup Wizard
Incore lookups are used when lookup data can fit in memory. This is the fastest type of lookup. It includes the following functions for each result field:
• Clear function
• AddRow function
• ChangeRow function
• RemoveRow function
• Init function
• Lookup function
It also includes a WriteToFile function.
To create an Incore lookup EZscript library:
1. Select a DataConnect project and do any of the following:
• Go to File > New > EZscript Library.
• Click the arrow in
and then click
EZscript Library.
• Right-click on the project and then click New > EZscript Library.
The New EZscript Library dialog is displayed.
2. Specify the following:
• Select a file extension - Select ezscript, bas, or rifl to specify the file extension.
• Select a type of EZscript Library - Select Lookup.
• Select a lookup type - Select Incore.
3. Click Next.
The Define your Lookup Connection dialog is displayed.
4. Specify the fields to connect to the database, define the lookup, and click Connect.
5. Click Next.
The Confirm Lookup Data dialog displays the data that is fetched from the database based on the criteria specified in step 5.
6. Verify the data and click Next.
The Confirm Connect String dialog displays the string used to connect to the database.
7. Click Next.
The Select a key field and one or more result fields dialog is displayed.
8. Do the following:
• Include - Select the required check box to specify the key field and the result field.
• Key - Click within the cell and select Yes to specify the field that must be used for the lookup key. Else, select No. By default, Yes and No are selected for fields.
• Default Value - Click within the cell and type the default value for the field (if required). For each field that is returned, you must provide a default value in case the lookup key cannot be found in the file.
9. Click Next.
The Confirm key field and result field(s) dialog is displayed.
10. Verify and click Next.
The Create a new EZscript Library dialog is displayed.
11. In the EZscript Library Name field, type a name for the EZscript file.
Note: The file name must not begin with a number.
12. Click Finish.
A new EZscript library file in incore format is created and it opens as a separate tab. The file extension is .ezscript, .bas, or .rifl based on your selection in step 2.
For more information about EZscript, see
Scripting.