description: keywords: —
Using Tokens
You can capture and store data within the user token area of a trail record header. Token data can be retrieved and used in many ways to customize the way that Oracle GoldenGate delivers information.
For example, you can use token data in:
-
Column maps
-
Stored procedures called by a
SQLEXECstatement -
User exits
-
Macros
Defining Tokens
To use tokens, you define the token name and associate it with data. The data can be any valid character data or values retrieved from Oracle GoldenGate column-conversion functions.
The token area in the record header permits up to 16,000 bytes of data. Token names, the length of the data, and the data itself must fit into that space.
To define a token, use the TOKENS option of the TABLE parameter in the Extract parameter file.
Syntax
TABLE table_spec, TOKENS (token_name = token_data [, ...]);
Where:
-
table_spec is the name of the source table. A container or catalog name, if applicable, and an owner name must precede the table name.
-
token_name is a name of your choice for the token. It can be any number of alphanumeric characters and is not case-sensitive.
-
token_data is a character string of up to 2000 bytes. The data can be either a string that is enclosed within single quotes or the result of an Oracle GoldenGate column-conversion function. The character set of token data is not converted. The token must be in the character set of the source database for Extract and in the character set of the target database for Replicat. In the trail file, user tokens are stored in UTF-8.
TABLE ora.oratest, TOKENS (
TK-OSUSER = @GETENV ('GGENVIRONMENT' , 'OSUSERNAME'),
TK-GROUP = @GETENV ('GGENVIRONMENT' , 'GROUPNAME')
TK-HOST = @GETENV('GGENVIRONMENT' , 'HOSTNAME'));
As shown in this example, the Oracle GoldenGate @GETENV function is an effective way to populate token data. This function provides several options for capturing environment information that can be mapped to tokens and then used on the target system for column mapping.
Using Token Data in Target Tables
To map token data to a target table, use the @TOKEN column-conversion function in the source expression of a COLMAP clause in a Replicat MAP statement. The @TOKEN function provides the name of the token to map. The COLMAP syntax with @TOKEN is:
Syntax
COLMAP (
The following MAP statement maps target columns host, gg_group, and so forth to tokens tk-host, tk-group, and so forth. Note that the arguments must be enclosed within single quotes.
| User tokens | Values |
|---|---|
tk-host |
:sysA |
tk-group |
:extora |
tk-osuser |
:jad |
tk-domain |
:admin |
tk-ba_ind |
:B |
tk-commit_ts |
:2011-01-24 17:08:59.000000 |
tk-pos |
:3604496 |
tk-rba |
:4058 |
tk-table |
:oratest |
tk-optype |
:insert |
Example 9-10 MAP Statement
MAP ora.oratest, TARGET ora.rpt,
COLMAP (USEDEFAULTS,
host = @token ('tk-host'),
gg_group = @token ('tk-group'),
osuser= @token ('tk-osuser'),
domain = @token ('tk-domain'),
ba_ind= @token ('tk-ba_ind'),
commit_ts = @token ('tk-commit_ts'),
pos = @token ('tk-pos'),
rba = @token ('tk-rba'),
tablename = @token ('tk-table'),
optype = @token ('tk-optype'));
The tokens in this example will look similar to the following within the record header in the trail: