pull values from database and pass to tRunJob as values for parameters

One Star

pull values from database and pass to tRunJob as values for parameters

I have a table (pic 1) that contains information that I want to, pull with tMSSqlInput and, pass as Context Parameters, via tRunJob (pics 2-5), to a sub-Job (dummy process currently, shown in pic 8, the actual process is what is deactivated above in the pic). I want it to loop through every row in the table and pass the information to tRunJob.
But I am having trouble getting the main routine to work (pics 6 & 7)

Starting job MainRoutine_DeleteFiles at 17:13 03/06/2008.
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles cannot be resolved to a type
notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles cannot be resolved
notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles cannot be resolved
notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles cannot be resolved
notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles cannot be resolved
connecting to socket on port 3432
connected
connecting to socket on port 4426
connected
Job MainRoutine_DeleteFiles ended at 17:13 03/06/2008.


One Star

Re:pull values from database and pass to tRunJob as values for parameters

ok, based on this topic http://talendforge.org/forum/viewtopic.php?pid=7497, I tried adding tLogRow to my job, but that still doesnt work

Starting job MainRoutine_DeleteFiles at 17:49 03/06/2008.
TargetFolder Extension_FileName NumDaysRetain
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )
at notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles.tContextDump_1Process(Copy_of_SubRoutine_DeleteFiles.java:301)
at notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles.runJobInTOS(Copy_of_SubRoutine_DeleteFiles.java:666)
at notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles.runJob(Copy_of_SubRoutine_DeleteFiles.java:566)
\gwpack\import\|*.zip|45.0
at notifications.mainroutine_deletefiles_0_1.MainRoutine_DeleteFiles.tMSSqlInput_2Process(MainRoutine_DeleteFiles.java:540)
Job MainRoutine_DeleteFiles ended at 17:49 03/06/2008.


Community Manager

Re:pull values from database and pass to tRunJob as values for parameters

Hello

Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )


Because there is a special charater'\' in your targetfolder column, so you need to escape '\' before pass it to child job. For example: \file1\file2 ===>\\file1\\file2
I have tested with tJavaRow component, it works with the expression:

String.replaceAll("\\\\","\\\\\\\\")


see the screenshot.
Best regards
shong

----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re:pull values from database and pass to tRunJob as values for parameters

Try #1 (the pictures attached are for this try)

row2.TargetFolder=row1.TargetFolder.replaceAll("\\\\","\\\\\\\\");

 

Starting job MainRoutine_DeleteFiles at 11:50 04/06/2008.
Exception in component tJava_1
java.lang.NullPointerException
at notifications.mainroutine_deletefiles_0_1.MainRoutine_DeleteFiles.tMSSqlInput_2Process(MainRoutine_DeleteFiles.java:517)
at notifications.mainroutine_deletefiles_0_1.MainRoutine_DeleteFiles.runJobInTOS(MainRoutine_DeleteFiles.java:913)
at notifications.mainroutine_deletefiles_0_1.MainRoutine_DeleteFiles.main(MainRoutine_DeleteFiles.java:820)
Job MainRoutine_DeleteFiles ended at 11:50 04/06/2008.


I tried these because #1 didn't work, just to make sure I wasn't supposed to use the exact same thing you said in your example.
Try #2

output_row.folderpath=input_row.folderpath.replaceAll("\\\\","\\\\\\\\");

 

Starting job MainRoutine_DeleteFiles at 11:46 04/06/2008.
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
output_row cannot be resolved
input_row cannot be resolved
row2.filePath cannot be resolved or is not a field
at notifications.mainroutine_deletefiles_0_1.MainRoutine_DeleteFiles.tMSSqlInput_2Process(MainRoutine_DeleteFiles.java:516)
at notifications.mainroutine_deletefiles_0_1.MainRoutine_DeleteFiles.runJobInTOS(MainRoutine_DeleteFiles.java:913)
at notifications.mainroutine_deletefiles_0_1.MainRoutine_DeleteFiles.main(MainRoutine_DeleteFiles.java:820)
Job MainRoutine_DeleteFiles ended at 11:46 04/06/2008.


Try #3

output_row.TargetFolder=input_row.TargetFolder.replaceAll("\\\\","\\\\\\\\");

 

Starting job MainRoutine_DeleteFiles at 11:44 04/06/2008.
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
output_row cannot be resolved
input_row cannot be resolved
at notifications.mainroutine_deletefiles_0_1.MainRoutine_DeleteFiles.tMSSqlInput_2Process(MainRoutine_DeleteFiles.java:516)
at notifications.mainroutine_deletefiles_0_1.MainRoutine_DeleteFiles.runJobInTOS(MainRoutine_DeleteFiles.java:913)
at notifications.mainroutine_deletefiles_0_1.MainRoutine_DeleteFiles.main(MainRoutine_DeleteFiles.java:820)
Job MainRoutine_DeleteFiles ended at 11:44 04/06/2008.


One Star

Re:pull values from database and pass to tRunJob as values for parameters

then I tried using tReplace, instead of tJava (or tMap).
I set Search = "\" and Replace with = "\\", and got this error (first pic)

Starting job Copy_of_MainRoutine_DeleteFiles_a at 12:01 04/06/2008.
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method replaceAll(String, String) in the type String is not applicable for the arguments (String)
Syntax error, insert ")" to complete MethodInvocation
Syntax error, insert ";" to complete Statement
at notifications.copy_of_mainroutine_deletefiles_a_0_1.Copy_of_MainRoutine_DeleteFiles_a.tMSSqlInput_2Process(Copy_of_MainRoutine_DeleteFiles_a.java:638)
at notifications.copy_of_mainroutine_deletefiles_a_0_1.Copy_of_MainRoutine_DeleteFiles_a.runJobInTOS(Copy_of_MainRoutine_DeleteFiles_a.java:1024)
Job Copy_of_MainRoutine_DeleteFiles_a ended at 12:01 04/06/2008.


Then I set Search = "\\\\" and Replace with = "\\\\\\\\", and got this error

Starting job Copy_of_MainRoutine_DeleteFiles_a at 12:03 04/06/2008.
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )
at notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles.tContextDump_1Process(Copy_of_SubRoutine_DeleteFiles.java:301)
at notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles.runJobInTOS(Copy_of_SubRoutine_DeleteFiles.java:666)
at notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles.runJob(Copy_of_SubRoutine_DeleteFiles.java:566)
\\gwpack\\import\\|*.zip|45.0
at notifications.copy_of_mainroutine_deletefiles_a_0_1.Copy_of_MainRoutine_DeleteFiles_a.tMSSqlInput_2Process(Copy_of_MainRoutine_DeleteFiles_a.java:718)
at notifications.copy_of_mainroutine_deletefiles_a_0_1.Copy_of_MainRoutine_DeleteFiles_a.runJobInTOS(Copy_of_MainRoutine_DeleteFiles_a.java:920)
Job Copy_of_MainRoutine_DeleteFiles_a ended at 12:03 04/06/2008.


One Star

Re:pull values from database and pass to tRunJob as values for parameters

I tried using tMap instead of tJava...

StringHandling.EREPLACE(row1.TargetFolder ,"\\\\","\\\\\\\\")

 

Starting job Copy_of_MainRoutine_DeleteFiles_a at 11:55 04/06/2008.
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )
at notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles.tContextDump_1Process(Copy_of_SubRoutine_DeleteFiles.java:301)
at notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles.runJobInTOS(Copy_of_SubRoutine_DeleteFiles.java:666)
at notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles.runJob(Copy_of_SubRoutine_DeleteFiles.java:566)
\\gwpack\\import\\|*.zip|45.0
at notifications.copy_of_mainroutine_deletefiles_a_0_1.Copy_of_MainRoutine_DeleteFiles_a.tMSSqlInput_2Process(Copy_of_MainRoutine_DeleteFiles_a.java:753)
at notifications.copy_of_mainroutine_deletefiles_a_0_1.Copy_of_MainRoutine_DeleteFiles_a.runJobInTOS(Copy_of_MainRoutine_DeleteFiles_a.java:956)
at notifications.copy_of_mainroutine_deletefiles_a_0_1.Copy_of_MainRoutine_DeleteFiles_a.main(Copy_of_MainRoutine_DeleteFiles_a.java:863)
Job Copy_of_MainRoutine_DeleteFiles_a ended at 11:55 04/06/2008.


One Star

Re:pull values from database and pass to tRunJob as values for parameters

ok I changed the data in the table (pic 1) so that the values in TargetFolder don't end with \, but I'm still getting errors
(I also tried removing the leading \, but still get the errors below)
tMap (pics 2-4)

StringHandling.EREPLACE(row1.TargetFolder ,"\\\\","\\\\\\\\")

 

Starting job Copy_of_MainRoutine_DeleteFiles_a at 14:41 04/06/2008.
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )
at notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles.tContextDump_1Process(Copy_of_SubRoutine_DeleteFiles.java:301)
at notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles.runJobInTOS(Copy_of_SubRoutine_DeleteFiles.java:668)
at notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles.runJob(Copy_of_SubRoutine_DeleteFiles.java:568)
\gwpack\import|*.zip|45.0
\\gwpack\\import|*.zip|45.0
at notifications.copy_of_mainroutine_deletefiles_a_0_1.Copy_of_MainRoutine_DeleteFiles_a.tMSSqlInput_2Process(Copy_of_MainRoutine_DeleteFiles_a.java:1002)
at notifications.copy_of_mainroutine_deletefiles_a_0_1.Copy_of_MainRoutine_DeleteFiles_a.runJobInTOS(Copy_of_MainRoutine_DeleteFiles_a.java:1233)
Job Copy_of_MainRoutine_DeleteFiles_a ended at 14:41 04/06/2008.


tReplace (pics 5 & 6)

Search = "\\\\" and Replace with = "\\\\\\\\"

 

Starting job Copy_of_Copy_of_MainRoutine_DeleteFiles_a at 14:51 04/06/2008.
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Syntax error on token ".", delete this token
at notifications.copy_of_copy_of_mainroutine_deletefiles_a_0_1.Copy_of_Copy_of_MainRoutine_DeleteFiles_a.tMSSqlInput_2Process(Copy_of_Copy_of_MainRoutine_DeleteFiles_a.java:1087)
at notifications.copy_of_copy_of_mainroutine_deletefiles_a_0_1.Copy_of_Copy_of_MainRoutine_DeleteFiles_a.runJobInTOS(Copy_of_Copy_of_MainRoutine_DeleteFiles_a.java:1360)
at notifications.copy_of_copy_of_mainroutine_deletefiles_a_0_1.Copy_of_Copy_of_MainRoutine_DeleteFiles_a.main(Copy_of_Copy_of_MainRoutine_DeleteFiles_a.java:1266)
Job Copy_of_Copy_of_MainRoutine_DeleteFiles_a ended at 14:51 04/06/2008.


tJava (pics 7 & 8)

row2.TargetFolder=row3.TargetFolder.replaceAll("\\\\","\\\\\\\\");

 

Starting job MainRoutine_DeleteFiles at 14:57 04/06/2008.
Exception in component tJava_1
java.lang.NullPointerException
at notifications.mainroutine_deletefiles_0_1.MainRoutine_DeleteFiles.tMSSqlInput_2Process(MainRoutine_DeleteFiles.java:686)
at notifications.mainroutine_deletefiles_0_1.MainRoutine_DeleteFiles.runJobInTOS(MainRoutine_DeleteFiles.java:1190)
at notifications.mainroutine_deletefiles_0_1.MainRoutine_DeleteFiles.main(MainRoutine_DeleteFiles.java:1097)
Job MainRoutine_DeleteFiles ended at 14:57 04/06/2008.


I don't care what component I use to do this (whether its tJava, tMap, tReplace, or something else), btw

One Star

Re: pull values from database and pass to tRunJob as values for parameters

I tried changing the SQL code to do the substitution in the original statement (pic 1), but I still get an error

select REPLACE(targetfolder,'\','\\') as TargetFolder, Extension_FileName, NumDaysRetain
FROM Analysis.smfadm.tblOdyssey_FileCleanUp_Variables

 

Starting job Copy_of_Copy_of_MainRoutine_DeleteFiles_a at 16:35 04/06/2008.
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Syntax error on token ".", delete this token
at notifications.copy_of_copy_of_mainroutine_deletefiles_a_0_1.Copy_of_Copy_of_MainRoutine_DeleteFiles_a.tMSSqlInput_2Process(Copy_of_Copy_of_MainRoutine_DeleteFiles_a.java:566)
at notifications.copy_of_copy_of_mainroutine_deletefiles_a_0_1.Copy_of_Copy_of_MainRoutine_DeleteFiles_a.runJobInTOS(Copy_of_Copy_of_MainRoutine_DeleteFiles_a.java:786)
at notifications.copy_of_copy_of_mainroutine_deletefiles_a_0_1.Copy_of_Copy_of_MainRoutine_DeleteFiles_a.main(Copy_of_Copy_of_MainRoutine_DeleteFiles_a.java:692)
Job Copy_of_Copy_of_MainRoutine_DeleteFiles_a ended at 16:35 04/06/2008.


I tried REPLACE(targetfolder,'\','\\\\') and REPLACE(targetfolder,'\','\\\\\\\\'), with the same error results

Community Manager

Re:pull values from database and pass to tRunJob as values for parameters

Hello strpdsnk

Try #2
Code:
output_row.folderpath=input_row.folderpath.replaceAll("\\\\","\\\\\\\\");
Starting job MainRoutine_DeleteFiles at 11:46 04/06/2008.
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
output_row cannot be resolved
input_row cannot be resolved
row2.filePath cannot be resolved or is not a field
at notifications.mainroutine_deletefiles_0_1.MainRoutine_DeleteFiles.tMSSqlInput_2Process(MainRoutine_DeleteFiles.java:516)
at notifications.mainroutine_deletefiles_0_1.MainRoutine_DeleteFiles.runJobInTOS(MainRoutine_DeleteFiles.java:913)
at notifications.mainroutine_deletefiles_0_1.MainRoutine_DeleteFiles.main(MainRoutine_DeleteFiles.java:820)
Job MainRoutine_DeleteFiles ended at 11:46 04/06/2008.


1) Please use the tJavaRow replace the tJava component. If your schema column is 'TargetFolder', please use the expression:

row2.TargetFolder=row1.TargetFolder.replaceAll("\\\\","\\\\\\\\");


not row2.folderpath
2) Make sure there are not null value in your 'TargetFolder' column, otherwise, you need to use a tMap component deal with the null value.
Best regards

shong

----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: pull values from database and pass to tRunJob as values for parameters

1. doing that gives me this error: (and doesnt pass the 2nd, Extension_FileName, and 3rd, NumDaysRetain, columns)

Starting job Copy_of_MainRoutine_DeleteFiles_a at 22:22 04/06/2008.
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )
at notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles.tContextDump_1Process(Copy_of_SubRoutine_DeleteFiles.java:301)
at notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles.runJobInTOS(Copy_of_SubRoutine_DeleteFiles.java:668)
at notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles.runJob(Copy_of_SubRoutine_DeleteFiles.java:568)
\gwpack\import\|*.zip|45.0
\\gwpack\\import\\||
at notifications.copy_of_mainroutine_deletefiles_a_0_1.Copy_of_MainRoutine_DeleteFiles_a.tMSSqlInput_2Process(Copy_of_MainRoutine_DeleteFiles_a.java:963)
Job Copy_of_MainRoutine_DeleteFiles_a ended at 22:22 04/06/2008.


2. also, there are no null values in that column
but it isn't working in tMap when I've tried that...

Community Manager

Re:pull values from database and pass to tRunJob as values for parameters

Hello strpdsnk
Where do use the value of TargetFolder field in your child job? Can you upload a screenshot of child job?
Best regards

shong

----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re:pull values from database and pass to tRunJob as values for parameters

ok I activated part of the actual subjob I want it to run, not the dummy part
Pictures:
1 - Main Routine
2 - Sub Routine - first step
3 - Sub Routine - first step
4 - Sub Routine - first step
5 - Sub Routine - dummy and actual processes shown
Error with original tJavaRow code (row3.TargetFolder=row2.TargetFolder.replaceAll("\\\\","\\\\\\\\")Smiley Wink

Starting job Copy_of_MainRoutine_DeleteFiles_a at 14:00 05/06/2008.
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )
at notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles.tFileList_1Process(Copy_of_SubRoutine_DeleteFiles.java:525)
at notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles.runJobInTOS(Copy_of_SubRoutine_DeleteFiles.java:1005)
at notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles.runJob(Copy_of_SubRoutine_DeleteFiles.java:905)
\gwpack\import\|*.zip|45.0
\\gwpack\\import\\||
at notifications.copy_of_mainroutine_deletefiles_a_0_1.Copy_of_MainRoutine_DeleteFiles_a.tMSSqlInput_2Process(Copy_of_MainRoutine_DeleteFiles_a.java:964)
at notifications.copy_of_mainroutine_deletefiles_a_0_1.Copy_of_MainRoutine_DeleteFiles_a.runJobInTOS(Copy_of_MainRoutine_DeleteFiles_a.java:1193)
Job Copy_of_MainRoutine_DeleteFiles_a ended at 14:00 05/06/2008.


and I updated the code in tJavaRow to include the other 2 columns:

row3.TargetFolder=row2.TargetFolder.replaceAll("\\\\","\\\\\\\\");
row3.Extension_FileName=row2.Extension_FileName;
row3.NumDaysRetain=row2.NumDaysRetain;


Error with modified tJavaRow code

Starting job Copy_of_MainRoutine_DeleteFiles_a at 14:01 05/06/2008.
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )
at notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles.tFileList_1Process(Copy_of_SubRoutine_DeleteFiles.java:525)
at notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles.runJobInTOS(Copy_of_SubRoutine_DeleteFiles.java:1005)
at notifications.copy_of_subroutine_deletefiles_2_0.Copy_of_SubRoutine_DeleteFiles.runJob(Copy_of_SubRoutine_DeleteFiles.java:905)
\gwpack\import\|*.zip|45.0
\\gwpack\\import\\|*.zip|45.0
at notifications.copy_of_mainroutine_deletefiles_a_0_1.Copy_of_MainRoutine_DeleteFiles_a.tMSSqlInput_2Process(Copy_of_MainRoutine_DeleteFiles_a.java:966)
at notifications.copy_of_mainroutine_deletefiles_a_0_1.Copy_of_MainRoutine_DeleteFiles_a.runJobInTOS(Copy_of_MainRoutine_DeleteFiles_a.java:1195)
Job Copy_of_MainRoutine_DeleteFiles_a ended at 14:01 05/06/2008.


The sub job I want to send these context parameter values to is the job I was working on here 2920

One Star

Re: pull values from database and pass to tRunJob as values for parameters

This is still giving me problems. See my last post above.

One Star

Re:pull values from database and pass to tRunJob as values for parameters

Ok, I can pass one row from tMSSqlInput to tRunJob (pics 1-3)
And, I've tested it out, and using the same format (tMSSqlInput --row1 (main)--> tRunJob) works when you've got multiple rows being pulled from the database. It just does one row at a time.

One Star

Re: pull values from database and pass to tRunJob as values for parameters

Hello everybody,
maybe anyone could help me.
I'm beginning to use Talend Open Studio and I already get error messages.
Here is the message I get:

Starting job test2 at 14:27 19/06/2008.
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at module_4.test2_0_1.test2.main(test2.java:7727)
Job test2 ended at 14:27 19/06/2008.
I really can settle this problem and so, I can't keep on working.
Thank you.

One Star

Re:pull values from database and pass to tRunJob as values for parameters

1. you should post a new topic for this problem
2. you need to be more specific about what you've done - ie screenshots!

One Star

Re:pull values from database and pass to tRunJob as values for parameters

I also encountered similar issue and I got the resolution by changing the slash type (from back slash to front slash) while mentioning my target file address.

One Star

Re:pull values from database and pass to tRunJob as values for parameters

Hi,
I am working on loading data from a file to a table created in hive.
The error is as follows:
Exception in thread "main" java.lang.Error: Unresolved compilation problem: Invalid escape sequence (valid ones are  \b  \t  \n  \f  \r  \"  \'  \\ )
at local_project.just_hive_0_1.just_hive.tHiveConnection_1Process(just_hive.java:354)at local_project.just_hive_0_1.just_hive.runJobInTOS(just_hive.java:1115)at local_project.just_hive_0_1.just_hive.main(just_hive.java:972)
I also tried using\\, but it dint work