Seven Stars

tMap use column length in expression

Hi all,

 

is there any way to access the column length in the expression

please find the screenshot

Instead of numbers directly can i use the column length and if so can you please tell the syntax.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Ten Stars

Re: tMap use column length in expression

3 REPLIES
Employee

Re: tMap use column length in expression

Unfortunately no, you cannot access that variable.

 

Also, from a code logic perspective, it does not work.

 

First of all, you need to understand that the length for datatype String is only enforced when writing to a database.  Talend will not truncate your string if you are writing to a file unless you do so.  

Hence, the actual length of the string can be:

- Shorter that the length you defined

- Longer than the length you defined

- exactly the length as you defined

 

Hence, in 2 out of 3 cases, your transformation logic will be wrong.  

You need to get the actual length of the string and pass that into your substring function.

 

Seven Stars

Re: tMap use column length in expression

This job is only to separate the substrings from string and so the length mentioned in the design will be fixed and as far as writing to database is concerned, it will be a new job using the output file of the previous job.

anyways, it means the value has to be entered manually, there is no way that we can get the length.
else is there any design that i can use to separate substrings from a string using somethig else than tMap which can reduce the manual effort ?
thanks

Ten Stars

Re: tMap use column length in expression