Java Snippet at the start of a workflow?


Is it possible to start a KNIME workflow with a Java Snippet?  (One use  case: generate an SQL statement inside a Snippet, store this SQL in a flow variable and then use the value of the flow variable in a Database Reader. 

When I  try to build a workflow starting with a Java Snippet, this, the Snippet node stays red and 'execute' is disabled on the context menu.


The Java snippet needs an input node. You could have a Table Creator to make a single cell, edit this cell with the java snippet and then do your flow variable stuff?

You need the Empty Table Creator as your first node before the Java snippet.

But as you anyway want to use the value as a flow variable, you can use the "Java Edit Variable" node.

Cheers, Iris

If you want to store your result in a flow variable, you could used a Java edit variable node to start the workflow - the input port on these is optional.

Also, you might see some rather strange behaviour with flow variables created in Java Snippet nodes when they are supplied with empty tables... (The snippet code only evaluates for each table row)



Java Edit Variables sounds like the way to go.