Global variables

Hi,

Could anyone please show me how to create and use  aglobal variable?

Regards,

Giuseppa

Do you mean global in eclipse, global in workspace or global in workflow?

I think only the workflow can have variables, the others would require eclipse plugins to get support.

To set the workflow variables, just right-click on the workflow (in the KNIME Explorer) and select Workflow Variables from the context menu. There you can add/edit flow variables.

Cheers, gabor

Do you mean Global Variable Declaration in Java Snippet Row Filter?

Hi Gabor,

What is the difference between a work flow variable or a created global variable?  In what circunstnaces Would I create a global variable?

Thanks,

Giuseppa

Hi Giuseppa,

I am not sure what you mean by created global variable, though I try to describe what the workflow variables are. They are persisted, so you will get the same value that was saved till you modify them, even if you move the workflow to another workspace. The workflow variables created the way I described are available everywhere in the workflow (that is why I thought you meant these when you mentioned global), although I think you can push other flow variables to the stack hiding that value in certain parts of the workflow (so these are variables). The workflow variables are not avaialable in other workflows. There seems to be other "more global" variables, like knime.workspace, but I think that is artifically added to each workflow within the workspace when they are loaded (or imported, I am not sure). Did you mean global variable with a functionality like that? (Or even more general, like for example you create a new workspace with new workflows it should still have those value till you use the same KNIME? Or a compatible KNIME?)

Cheers, gabor

Hi Gabor,

I understand what you are saying.  My idea of global variable is that the variable can be seen by any component and one does not have to pass the variable along using a java snipet.  For example;  let's say that I have 10 keys to query a database table.  The data base table returns 8 records only  because the two non-matching keys do not exist in the database table; therefore I get an 8 records table.  If I make the keys global, I was wondering if the variable would be made immediately present to the database component so that  the non-matched inputs could be recovered as part of the output. This way, the resulting table would have 10 records, one for each key.  The remaing table fields corresponding to the non-matching keys would be returned as blank, null, ???  ...eTc. I am having a problem recovereing the records corresponding to non-mathing inputs, when the inputs do not exist in the database.  If the input does not exist in the database I can not recover the input records using a java snipet.

Usually, when I want to recover an input that does not return as query output I use a java snipet.  Lets's say return $$variable$$; and press the button of the selected data type.  I can do this when there are not records returned for those keys, but it will only pass along the keys that produced records.  I use this method in a loop, database node, fromVariable to Table column component, java snipet , loop end work flow.

Cheers,

Giuseppa