SETENV

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.

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.
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.
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".
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' .
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