In Xtract Universal you can define custom parameters that can be set dynamically when calling extractions. When using an SQL destination, these parameters are available for SQL commands.
A typical use case is the dynamization of WHERE-Clauses in table components. The following table extraction has a custom parameter WNAME in the WHERE-Clause:
Custom SQL Statement #
In the window Destination Settings you can use a custom SQL statement for the three database process steps and / or edit the SQL statement according to your requirements.
- In the main window select an extraction with a custom parameter in the WHERE-Clause (1).
- Click [Destination] (2). The window “Destination Settings” opens.
- Select the option Custom SQL from the drop-down-menus (3)(4) in the following sections:
- Click [Edit SQL]. The window “Edit SQL” opens.
Custom SQL Example for Custom Parameters #
In the following example the SAP table KNA1 is expanded by adding the column Custom_Parameter of the type NATIONAL CHARACTER VARYING(10). The column is filled dynamically by runtime parameters.
In the section Row Processing the column values from SAP are written into the previously created SQL target table.
This SQL-statement is therefore used as the default Insert statement.
When rows are processed only
NULL values are written into the Custom_Parameter column.
In the section Finalization these
NULL values are replaced using the SQL statements of the runtime parameter WNAME and the T-SQL command
Note: The data types that can be used in SQL statements depend on your SQL database version.
- In the window “Destination Settings” select the option Custom SQL in the section Preparation. Click Edit SQL.
- Select Drop & Create from the drop-down-menu and click [Generate Statement] (6).
- Add the following line to the generated statement:
[Custom_Parameter] NATIONAL CHARACTER VARYING(10)
- Click [OK] to confirm your input.
- In the window “Destination Settings” select the option Custom SQL in the section Finalization. Click Edit SQL.
- Select Insert from the drop-down-menu and add the following SQL statement (7):
UPDATE [dbo].[KNA1] SET [Custom_Parameter] = @WNAME WHERE [Custom_Parameter] IS NULL;
- Click [OK] to confirm your input (5).
Set the Custom Parameter WNAME #
- Select the checkbox next to the parameter name to overwrite the parameter WNAME.
- Enter the new value US and confirm your input by pressing enter.
- Click [Run] (8) to run the extraction.
Result in SSMS #
Check the result of the column Custom_Parameter in the SQL Server View of the KNA1 table.