[resolved] Question about TJavaRow comparing string values.
I need to compare global variable value with string value. And if condition JOB must be stopped. I did this on TJavaRow: System.out.println("My value " + globalMap.get("IsLocked")) ; if (globalMap.get("IsLocked") == "N") {System.out.println("Then");} else {throw new RuntimeException("----Raise error-------");}; Why condition doesn't work? It raises error while Println returns " My value N". Global variable type is Char.
Just add a tJavaRow after each tFilterRow to compute the number of rows using a dedicated global variable.
This way, you may avoid to call the txxxxxOutput components when the corresponding number of rows is equal to 0.
This is a solution, many other may exist as TOS is very adaptable.
TRF
Hi walkerca,
now code looks like:
System.out.println("My value " + globalMap.get("IsLocked")) ;
if (( (String)globalMap.get("IsLocked") ).equals("N")) {System.out.println("Then");}
//else {System.out.println("Then2");};
else {throw new RuntimeException("----Raise error-------");};
But i get error:
Exception in component tJavaRow_2
java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.String
When i remove (String) option it doesn't compares values in right way. I mean runs "---- Raise error ---" while value is "N" Println returns - My value N
I tried IsLocked in MSSQLInput Edit schema change DB type between CHAR and VARCHAR but it didn't help..
EDIT : need to change Type to String in Edit Schema.
Thanks.
Hii everyone, I am very new to talend. I have a flat file in .csv form. In the flat file there is a field which can have values like lms/spar/max. It is mandatory that at least once these three names has to occur in the flat-file. If the File don't have any one of this option, I have to send a mail. What should I do? I tried something like this: FileInputDelimited -> tjavarow ->runif -> tsendmail I tried using flag to check if any of these option are not present. But its showing error as 'flag cannot be resolved to a variable'! please tell me a way out to solve this problem.
Hi, Use a tFilter to get records with one of the three values mls/spar/max. If no row goes to the the filtered output, then no records contains the desired values and you can go with tSendMail. No tJavaRow required for this. Regards, TRF
Hi, Thanks a bunch TRF for your suggestion. But I am already using three filters to send the LMS/SPAR/MAX into its respective database table. So now how should I check whether there is data passing through it or not. my whole process looks like this FileInputDelimited -> tmap -> tfilterrow -> lms data into lms database |_ -> tfilterrow -> spar data into spar database |_ -> tfilterrow -> max data into max database Now how should I add a check in tfilter row to check if no row is passing through it into the database.
Just add a tJavaRow after each tFilterRow to compute the number of rows using a dedicated global variable.
This way, you may avoid to call the txxxxxOutput components when the corresponding number of rows is equal to 0.
This is a solution, many other may exist as TOS is very adaptable.
TRF
Hi,
I wanted the flag..I need to use it in the further process.
My Code which I am inserting in tjavarow is as below:
int flag1=0, flag2=0;
if (output_row.OU_CODE.equals("LMS"))
flag1 = 1;
else (output_row.OU_CODE.equals("SPAR"))
flag2 = 1;
But tjavarow is giving me errors like..
Please help me write this code well so that tjavarow wont give me errors. Also After tjava row I have runif condition which will check if flag1==0 || flag2==0 and then send a mail.