Welcome Guest! Log in


When working with files in Stambia, there might be a need to name them dynamically, depending on parameters, time, ...

This article shows some ways to accomplish that.

With StartDelivery

When executing a delivery with the startdelivery utility, variables can be added in the command. They will be published in the process during the execution.

These variables can be used to modify the name of the files.

For that, the first step is to configure the file metadata or the template configuration, to use a variable in the file name.

In the metadata :

In the metadata, the variable has to be put in the Physical name property.

The syntax is ${~/variableName}$

With this solution, all the mappings using this file will have to be started with the fileName parameter.

MetadataPhysicalNameConfiguration

In the template :

In the template properties, the variable can be put directly in the Out File Name property.

With this solution, unlike the metadata one, only this mapping will be affected by the dynamic name.

templateConfiguration

 

Starting the delivery

Finally, the delivery has to be started started with the variable used in the file name.

startdelivery.bat -name dynamicNamingFromDelivery -var ~/fileName dynamicNaming

-> The file will be named customers_dynamicNaming.txt

 

With a Metadata Variable (using timestamp)

Metadata Variables can also be used for dynamic naming. Here is an example to use it to add a timestamp at the end of the file name.

The timestamp is set in the default Value of the metatdata variable with %x{md:formatDate('formatOfDate')}x%

Examples of date formats :

Date/Moment Expression Result
Today %x{md:formatDate('yyyyMMdd')}x% 20171129
Yesterday %x{md:formatDate('yyyyMMdd', "-1")}x% 20171128
Tomorrow %x{md:formatDate('yyyyMMdd', "1")}x% 20171130
Now %x{md:formatDate('yyyyMMdd-HHmmss.SSS')}x% 20171129-172756.077
Six hours ago %x{md:formatDate('yyyyMMdd-HHmmss.SSS', "-6/24")}x% 20171129-112756.077
Six hours ahead %x{md:formatDate('yyyyMMdd-HHmmss.SSS', "6/24")}x% 20171129-232756.077

 

 variableset

The variable can then be used in the Physical Name of the file, with %{variableName}%

MetadataFilePathVariableConfiguration

Note :

Don't forget to drag and drop the variable in the metadata, at the same level as the file.

Finally, the variable needs to be dragged and dropped on the mapping.

MappingWithVariable

 

With Bind

Finally, the result of a bind can also be used in the name of a file. See this article which shows how to use SQL Operations with binds and the use of :{column}: syntax

Here is a Process example :

bindProcess

 

You have no rights to post comments

Articles

Suggest a new Article!