Valid for
Extract, Replicat
Description
Use SETENV
to set a NonStop environment variable. When Extract or Replicat starts, it uses the specified value instead of the one set in the environment.
Use one SETENV
statement per variable to be set. Any variables set in the SETENV
statement override any existing variables set at the operating-system level.
Setting Variables
The results from setting variables with SETENV
vary based on the quotation marks used.
No quotation marks
When no quotation marks are used, the result is upshifted so for SETENV (NAME = name1),
the result is NAME1
.
For example:
SETENV repl = replicat Set environment variable (REPL=REPLICAT) SETENV (repa = repall) Set environment variable (REPA=REPALL) ?repl ?repa 2013-05-06 14:33:48 OGG ?REPL = REPLICAT ?REPA = REPALL.
Double quotation marks
When double quotation marks are used, the quotation marks are removed from the result, which is otherwise unchanged. For SETENV NAME = "Name"
, the result is Name
.
For example:
SETENV name = "Name" Set environment variable (NAME=Name) MAP $data01.abdat.tcustmer, TARGET $data02.abdat.tcustmer, COLMAP (USEDEFAULTS, name = ?name); 2013-05-06 14:33:48 OGG ?NAME = Name.
Outer single quotation marks
When the value is enclosed in single quotation marks, the result is enclosed in double quotation marks and otherwise unchanged. For SETENV NAME = 'a literal'
, the result is "a literal"
.
For example:
SETENV name = 'With Single quotes, we get a literal' Set environment variable (NAME="With Single quotes, we get a literal") MAP $data01.abdat.tcustmer, TARGET $data02.abdat.tcustmer, COLMAP (USEDEFAULTS, name = ?name); 2013-05-06 14:33:48 OGG ?NAME ="With Single quotes, we get a literal".
Outer double quotation marks
When outer double and inner single quotation marks are used, the result is still everything within the double quotation marks unchanged. For SETENV NAME = "'name'"
, the result is 'name'
.
For example:
SETENV WILL = "'WILL'" Set environment variable (WILL='WILL') MAP $data01.abdat.tcustmer, target $data02.abdat.tcustmer, COLMAP (USEDEFAULTS), SQLEXEC (ID ex1, TRACE ALL, BEFPREFILTER, ERROR RAISE, QUERY " select * from $data01.tssout.tcustmer " " WHERE cust_code = ?WILL ", PARAMS (c1 = cust_code ) ); 2013-05-06 14:33:48 OGG ?WILL = 'WILL' .
Embedded quotation marks
Use the escape character to retain embedded quotation marks. For SETENV
NAME
= 'John\'s', the result is "John's".
For example:
SETENV name ='Use the escape character for the embedded quote in John\'s name' Set environment variable (NAME="Use the escape character for the embedded quote in John's name") MAP $data01.abdat.tcustmer, TARGET $data02.abdat.tcustmer, COLMAP (USEDEFAULTS, name = ?name); 2013-05-06 14:33:48 OGG ?NAME ="Use the escape character for the embedded quote in John's name".
Default
None
Syntax
SETENV (environment_variable = value)
environment_variable
The name of the environment variable to be set.
value
'A value for the specified variable. The value may be enclosed in quotes. See Setting Variables in the Description section for details on how single and double quotation marks are interpreted.
Example
EXTRACT GGS01 SETENV (TRAIL1=$DATA01.LOGGER.A1) SETENV (TRAIL2=$DATA01.LOGGER.A2) FILE $*.*.*; EXTTRAIL ?TRAIL1 FILE $*.*.* EXTTRAIL ?TRAIL2