[resolved] SELECT query from tPostgresqlInput and storing reult in variable?

One Star

[resolved] SELECT query from tPostgresqlInput and storing reult in variable?

Hi.
My job is roughly this:
tFileList --(iterate)-> tFileInputDelimited --(row1)-> tMap --(out1)-> tPostgresqlOutput
  |
  |
(iterate2)
  |
  v
tPostgresqlInput (for calling SELECT function() to further process data in db)

ie. I load data from files (iterating) to a DB and after each
iteration, I call a function in tPostgresqlInput to further
process the data in the DB. The function returns a value
that I would like to write to a variable and later write to a
log file of as sort. But how do I write the value to a
variable?
Later in process the file writing part would connect to
the tFileList above with another iterate arrow (iterate3)
to log the file name loaded and the value returned from
the function, pretty much like this:
   ...
|
(iterate3)
|
v
tFileProperties-(row3)->tMap -(out3)-> tFileOutputDelimited

So basically my question is: how to write a single value
selected from tPostgresqlInput to a variable?
JB

Accepted Solutions
One Star

Re: [resolved] SELECT query from tPostgresqlInput and storing reult in variable?

OK, I solved this with tSetGlobalVar component like this:
tFileList --(iterate)-> tFileInputDelimited --(row1)-> tMap --(out1)-> tPostgresqlOutput
 |   |
 |   |
 | (iterate2)
 |   |
 |   v
 |  tPostgresqlInput --(row2)-> tSetGlobalVar
 |
 |
(iterate3)
 |
 v
tFileproperties --(row3)-> tMap --(out2)-> tFileOutputDelimited

Then in components:

tPostgresqlInput: add field in schema for the value (code)
tSetGlobalVar: "code" as key, row3.code for value
tMap: ((String)globalMap.get("code")) in out2

Please feel free to share better solutions.
JB

All Replies
Moderator

Re: [resolved] SELECT query from tPostgresqlInput and storing reult in variable?

Hi,
You can use tJavaRow  to save each value to a variable for re-use in the next Input component.

Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: [resolved] SELECT query from tPostgresqlInput and storing reult in variable?

OK, I solved this with tSetGlobalVar component like this:
tFileList --(iterate)-> tFileInputDelimited --(row1)-> tMap --(out1)-> tPostgresqlOutput
 |   |
 |   |
 | (iterate2)
 |   |
 |   v
 |  tPostgresqlInput --(row2)-> tSetGlobalVar
 |
 |
(iterate3)
 |
 v
tFileproperties --(row3)-> tMap --(out2)-> tFileOutputDelimited

Then in components:

tPostgresqlInput: add field in schema for the value (code)
tSetGlobalVar: "code" as key, row3.code for value
tMap: ((String)globalMap.get("code")) in out2

Please feel free to share better solutions.
JB