on 05-02-2012 11:08 AM
Hello All,
I need to put double quotes for each of the source field coming from file into target.
Although this can be achieved with existing mapping functions, can you provide me a udf which will accept the field and simply insert at the beginning and end a double quotes.
This will be easy for me as I need to do it for 40 fields.
Regards
Anandh.B
There would be a lot less work & maintenance involved if you used the receiver FCC you had asked about the other day.
Regards,
Ryan Crosby
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
have to write simple udf:
public String calculate1(String var1, Container container) throws StreamTransformationException{
return var1 = "''" + var1 + "''" ; ( here we have to provide 2 single quotes in double quotes bz if provide double quotes in double quotes then ll get error )
ex input is:
DYP0SAP
ex output is :
''DYP0SAP'' |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Well, you don't have to use two single quotes instead of one double quote (apart from it not being acceptable on the receiver side, in most cases; the fact that it looks identical to a human doesn't really mean that computers interpret it as equal). Simply precede the quote with a slash, like this: \" and the quote will not be interpreted as a special character, so you won't get any error. So for instance if you use:
System.out.println("\"");
it outputs a double quote, as required here.
Regards,
Greg
Hello,
I don't know, isn't it easier to copy an existing field mapping with the double quotes and then paste it 40 times and then just replace the copied fields with the correct one?
Regards,
Mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Use this UDF, with execution type all values of queue:
for (int i = 0; i < input.length; i++) {
if (!(input[i].equals(ResultList.CC) OR (input[i].equals(ResultList.SUPPRESS)) {
result.addValue("\"" + input[i] + "\"");
}
}
Hope this helps,
Greg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
The following udf gave me the following error.
Looks like a long time since I have last written Java code... I've completely forgotten that Java uses || for OR in conditions. This code should work well for you, I've just compiled it:
for (int i = 0; i < input.length; i++) {
if (!(input[i].equals(ResultList.CC) || input[i].equals(ResultList.SUPPRESS))) {
result.addValue("\"" + input[i] + "\"");
}
}
Remember to set the execution type to all values of queue. And sorry for the confusion...
Regards,
Greg
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.