Specifying SQL Command at Runtime
This procedure describes how to configure a dataflow to support runtime options for SQL Command and also how to specify the job executor arguments to do this.
- Open the flow in Spectrum Enterprise Designer.
- If you want to configure runtime options for a stage in an embedded flow, open the embedded flow.
- Click the Dataflow Options icon on the toolbar or click Dataflow Options dialog box appears. . The
- Click Add. The Define Dataflow Options dialog box appears.
- Expand the SQL Command stage.
-
Select a SQL Command option. It can be PreSqlCommand,
SqlCommand, or
PostSqlCommand.
- PreSqlCommand
- SQL statements that you want to execute before the records coming into the stage are processed. These SQL statements are executed once per run after the dataflow starts running but before the SQL Command stage processes the first record.
- SqlCommand
- SQL statements you want to execute for each record in the dataflow.
- PostSqlCommand
- SQL statements that you want to execute after all the records are processed. These SQL statements are executed once per run after the SQL Command stage is finished but before the dataflow finishes.
The selected SQL Command option name is displayed in Option name and Option label fields. This is the option name that will have to be specified at run time in order to set this option. - Enter a description of the option in the Description field.
- In the Target field, select the option Selected stage(s).
- If you want to limit the values that can be specified at runtime, edit the options in the Legal values field by clicking on the icon just to the right of the field.
-
If you want to change the default value, specify a different value in the
Default value field.
Note: For a service, you can only modify default values before exposing the service for the first time. Once you expose the service you can no longer modify default values using Spectrum Enterprise Designer. Instead, you must use Spectrum Management Console. For more information, see Specifying Default Service Options.
- Click OK.
- Continue adding options as desired.
- Click OK in the Dataflow Options dialog box when you are done adding options.
- Save and expose the dataflow.
-
Create a text file containing the SQL statement you want to use at
runtime.
The text file may look like this:
SqlCommand = UPDATE CustomersSET ContactName='Alfred Schmidt' City='Hamburg' WHERE CustomerName='Alfreds Futterkiste';
In this example, SqlCommand is one of the SQL Command stage's option names.
-
Use the -o argument when running a job executor from command line.
java -jar jobexecutor.jar -h "noipa019sh-l1" -u "admin" -p "admin" -s "8080" -o "options.txt" -j "FetchOracleData" -w
The filename (options.txt) specifies a name of the text file that you created in step 14.For more information, see Running A Job from the Command Line