Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I tried to create local variable(s) inside the expression builder, to get an array of strings as return value:
As I just started using Talend, the idea above is not working.
Error messages:
My questions:
I feel I really miss something trivial.
Thanks,
István
For the complex scripts (and even complex data types) look at Routines. You can write your own Java classes and use with the expression builder. I have several tutorials of differing complexity on my website, but this one may be of interest for a simple example using a Routine (https://www.rilhia.com/tutorials/creating-random-test-data-using-talend-data-integration).
To do what you are trying to do, you need to think in a different way. In the expression builder, you can only use one line of Java code at a time. This makes it trickier to work with, but there are always workarounds (a Routine is a good workaround). What you are trying to build is a String array. This might be tricky (impossible I would suggest) in the way you are trying it. But you can use a Routine for this OR use an ArrayList to achieve this. Talend actually implements a List data type which is essentially the java.util.List class.
Another thing I will suggest is that if you are new to Talend, maybe ask us about your requirement. A lot of the time there is a different way of solving a problem in Talend that new users do not realise. It might be that you are making this a little more complicated than it needs to be.
I think, I will have to learn java, I cannot avoid it.
For the string array declaration/definition I already figured out, what is the right way:
String numbers_strarray[] = {"service1", row3.service1};
Regarding, how to return this array is still a question.
Hi,
I've personaly never seen it before (not saying it's impossible).
Can you give us some information about your use case?
What do you expect? How are the input data? What is the expected result?
For the complex scripts (and even complex data types) look at Routines. You can write your own Java classes and use with the expression builder. I have several tutorials of differing complexity on my website, but this one may be of interest for a simple example using a Routine (https://www.rilhia.com/tutorials/creating-random-test-data-using-talend-data-integration).
To do what you are trying to do, you need to think in a different way. In the expression builder, you can only use one line of Java code at a time. This makes it trickier to work with, but there are always workarounds (a Routine is a good workaround). What you are trying to build is a String array. This might be tricky (impossible I would suggest) in the way you are trying it. But you can use a Routine for this OR use an ArrayList to achieve this. Talend actually implements a List data type which is essentially the java.util.List class.
Another thing I will suggest is that if you are new to Talend, maybe ask us about your requirement. A lot of the time there is a different way of solving a problem in Talend that new users do not realise. It might be that you are making this a little more complicated than it needs to be.