Referencing Job Variables in a Job Script - Parallel Transporter

Teradata Parallel Transporter User Guide

Product
Parallel Transporter
Release Number
15.10
Language
English (United States)
Last Update
2018-10-07
dita:id
B035-2445
lifecycle
previous
Product Category
Teradata Tools and Utilities

Referencing Job Variables in a Job Script

To specify a job variable in a job script, reference the variable where the value would normally appear. The job variable reference is composed of the @ symbol, followed by a unique identifier for the variable. You can use the attribute name or any other identifier to construct the variable.

Example : Specifying Variables for Attributes

DEFINE JOB CREATE_SOURCE_EMP_TABLE
(
      DEFINE OPERATOR DDL_OPERATOR
      DESCRIPTION 'Teradata Parallel Transporter DDL Operator'
      TYPE DDL
      ATTRIBUTES
       (
          VARCHAR TdpID          = @TdpId,
          VARCHAR UserName       = @MyUserName,
          VARCHAR UserPassword   = @MyPassword
);
 
      APPLY
          ('DROP TABLE SOURCE_EMP_TABLE;'),
          ('CREATE TABLE SOURCE_EMP_TABLE(EMP_ID INTEGER, EMP_NAME CHAR(10));'),
          ('INSERT INTO SOURCE_EMP_TABLE(1,''JOHN'');'),
          ('INSERT INTO SOURCE_EMP_TABLE(2,''PETER'');')
      TO OPERATOR (DDL_OPERATOR);
);

In this example, the DDL operator issues two DDL and two DML statements that create a table and then populates that table with two rows. The values of the TdpId, UserName, and UserPassword operator attributes are specified as job variables.

Example : Specifying Non-Operator-Attribute Job Variables

Although the most common use of job variables is to specify the value for an operator attribute, job variables can also be used for object names and other job script parameters. In the following example, the values for @ConsumerOperator and @ProducerOperator can be assigned in the global job variables file, in a local job variables file, in a tbuild command, or in a job script using the SET directive.

   APPLY
      'INSERT INTO TABLE xyz (:col1, :col2);'
      TO OPERATOR ( @ConsumerOperator [1] )
      SELECT * FROM OPERATOR ( @ProducerOperator[2] );

Job variable can also be used in a quoted string for DML and DDL statements:

   'INSERT INTO TABLE ' || @TargTable || ' (:col1, :col2, . . ., :coln);'