How to Use RenameExpression to Name New Files
Question
How can I use the RenameExpression parameter to name new files?
Environment
HVR 5
Answer
Imagine you want to place your new replicated files depending on the timestamp when it was replicated or from which channel or from which capture location (database location). Below we will see how these expressions can be used and their variations.
By default, if the /RenameExpression parameter is not set, HVR creates a CSV file with current timestamp-table_name. In our case, a file called 20180613013511263-table1.csv is created, where 20180613013511263 is a timestamp and table1 is the table name.
Pre-requisites
A channel is already created on the Oracle source and a file target.
Table table1 is already added to the list of tables.
Action Fileformat /Csv is added to the target to get a file in the CSV format.
The RenameExpression parameter is added to the Target group.
Steps
Add the following action to get the integrate timestamp for the file:
CHANNEL GROUP TABLE LOCATION ACTION chn1 TGT * * Integrate /RenameExpression={hvr_integ_tstamp}.csv Add the following action to get the specifics of integrate timestamp. For example, to create directories for year, month and day:
CHANNEL GROUP TABLE LOCATION ACTION chn1 TGT * * Integrate /RenameExpression="{hvr_integ_tstamp %Y}/{hvr_integ_tstamp %m}/{hvr_integ_tstamp %d}/{hvr_integ_tstamp %H}/{hvr_tbl_name}.csv"
These are the few samples which are commonly used, but there are more expressions that can be used for a similar purpose and are listed in our manual. For more information, see Integrate Parameters.