BatchRunner job methods

  • 18 July 2022
  • 0 replies
  • 130 views

Userlevel 3
Badge +2

This article is about job methods of the BatchRunner internal component.

BatchRunner.job

For each job, the internal BatchRunner component automatically contains a job method that has the same name as the job. Calling the job method executes the job.

A job method returns a record set if the job has an output parameter set. Otherwise, it returns the NULL value. If a record set is returned, each record has as many column values are there are elements in the output parameter set.

Syntax 1

INVOKE   BatchRunner.job 
WITH
SELECT value parameter
, ...

Parameters (if any) are passed in the SELECT output list. Value is a SQL column expression, and parameter is a column alias. A column alias that contains a special symbol such as a space ( ) or a hyphen must be surrounded by double quotes to avoid misinterpretation of the special symbol by the SQL parser. Double-quoting of column aliases is always legal.

Parameters are always passed by name and may appear in any order.

Syntax  2

If the job call returns at most one (that is: 0 or 1) records and the job has exactly 1 output parameter, then you can use function call syntax as an alternative for INVOKE. In function call syntax, SELECT replaces INVOKE and the method name is followed by parentheses. Input parameters (if any) are passed inside the parentheses that follow the job name:

SELECT   BatchRunner.job (
value parameter
, ...
)

Example

A job called MyJob takes a contract_id value and returns a record structure defined by a primary key and two other columns. It may return any number of records or none at all. Returned records are inserted into a table T1. The job execution itself may involve any additional number of data manipulations.

INSERT INTO T1 (
pk
, col1
, col2
)
INVOKE BatchRunner.MyJob WITH
SELECT 'BZ-23' "contract_id"
, 'true' "-quiet"

In this example, -quiet is a predefined parameter.


0 replies

Be the first to reply!

Reply