You are not logged in.
Announcement
Unanswered posts
|
Pages: 1

hi folks,
i have a list of file names that need to be created and populated from a DB.
the source table is like this:
create table tb_fileListed(
filename varchar( 200 ),
recordType char(8),
recordContent varchar(4000)
)
at first i need to check if a file already exsts, and if not then create one.
my requirement is to place all files into a defined folder, this is defined as a variable in my job <baseFolder>.
i have created a mysql input to retrieve the dataset from the db, and connected to a tFolwToIterate.
and i thought that i would be able to connect to a tFileExists and then tFileTouch but i can not work out how to set the value for the file path since they only accept variables.
i suppose i can not see how to send the values from the row into a variable for each value.
i am sure this is something simple that i am missing out.
thanks,
Nicolas
Offline

Hi Nicolas,
the examples are for java:
You can retrieve the actual row (of tFlowToIterate) with the following syntax (in this example the connection to tFlowToIterate is named row1):
globalMap.get("row1.filename")To handle the folder you should define a context variable and create the filename as follows:
globalMap.get("row1.filename") + "/" + context.folderBye
Volker
Offline

hi volker,
i have created this job to understand your explanation.
but i can not receive any value for globalMap.get("row1.filename").
please have a look at the screenshot to see what i am missing.
i am trying to get the correct result in a message box at this point.
thanks,
Nicolas
Offline

Hi,
in your case use row2. The name of the key depends on the name of the input flow into tFlowToIterate.
Bye
Volker
Offline

many thanks,
Volker it worked just fine.
i did have a minor glitch, as i had to cast it as a string:
globalMap.get("row2.fileName").toString();
just so i do not need to disturb you with these simple question.
where do you find information about this type of classes of Talend? globalMap ??
i did check the documentation and could not find it anywhere.
Nicolas
Offline

Hi Nicolas,
yes you have to use toString() or cast the result. The hash is based on Object (i think).
To get more information about this you should read the code (as I have done).
There is no specific documentation about this (as I know).
Bye
Volker
Offline

thanks
Offline

just for reference
it can be done in a different way:
row generator
=>
tMap (manipulate rows)
=>
tJavaRow( set a variable with the value of a row [context.CURRENT_FILE = input_row.filename;]
=>
tFlowToIterate
=>
tTouchFile
Offline
Pages: 1