Solved

Variable Retriever not receiving value from Variable Setter

  • 12 October 2021
  • 7 replies
  • 17 views

Badge +5

Hello,

I am trying to obtain Max OBJECTID value from a database and pass it into Variable Setter.

The SQL Creator > Variable Setter is obtaining the correct value (just one record at present) but the Variable Retriever cannot obtain the value I think?

I hope this is a simple step or order I am missing.

Thanks in advance

icon

Best answer by nielsgerrits 12 October 2021, 14:32

View original

7 replies

Userlevel 6
Badge +33

Personally I would solve this in another way. I would use a FeatureMerger with values 1=1 to supply maxobjectid to all the requestors. Or use a FeatureReader initiated by the SQLExecutor and merge maxobjectid to all features when they are being read.

 

See the "Partial Run" warning, you are using FeatureCaching, first try if it works as expected with FeatureCaching turned off. I think this is your issue.

 

If this does not solve it, make sure the VariableSetter is run upstream of your VariableRetriever. The value needs to be set before it is retrieved, else it will retrieve nothing.

Badge +5

Personally I would solve this in another way. I would use a FeatureMerger with values 1=1 to supply maxobjectid to all the requestors. Or use a FeatureReader initiated by the SQLExecutor and merge maxobjectid to all features when they are being read.

 

See the "Partial Run" warning, you are using FeatureCaching, first try if it works as expected with FeatureCaching turned off. I think this is your issue.

 

If this does not solve it, make sure the VariableSetter is run upstream of your VariableRetriever. The value needs to be set before it is retrieved, else it will retrieve nothing.

Not sure how legible my workbench is but will hopefully give you an idea of the process.

 

As I already have a FeatureMerger i'm not sure if i can add another one (where?) or adapt the existing one (how?)

 

Turned caching off, it doesn't generate any polygons just the attributes.

 

The VariableSetter is upstream from the VariableSetter is it not?

 

Thank you

Userlevel 1
Badge +21

To ensure the variable is set before being retrieved, I would look at using feature readers to read the data and have them triggered by the output of the SQLcreator

Userlevel 6
Badge +33

Not sure how legible my workbench is but will hopefully give you an idea of the process.

 

As I already have a FeatureMerger i'm not sure if i can add another one (where?) or adapt the existing one (how?)

 

Turned caching off, it doesn't generate any polygons just the attributes.

 

The VariableSetter is upstream from the VariableSetter is it not?

 

Thank you

With you current setup it is possible that the SQLCreator fires after the other readers. The order on the Canvas has nothing to do with the order the initiation transformers (SQLCreator / Readers) are fired. I think the Readers will fire first, the SQLCreator as last. Remember, the workflow runs serial, not parallel.

 

If you replace the VariableRetriever with a FeatureMerger, connect the stream from the AttributeRounder to Requestor, SQLCreator to Supplier and set the "Join On" Requestor and Supplier Parameters both to 1, it will join the feature from the SQLCreator to each feature which passes the FeatureMerger.

 

2021-10-12_14h30_18

Badge +5

Not sure how legible my workbench is but will hopefully give you an idea of the process.

 

As I already have a FeatureMerger i'm not sure if i can add another one (where?) or adapt the existing one (how?)

 

Turned caching off, it doesn't generate any polygons just the attributes.

 

The VariableSetter is upstream from the VariableSetter is it not?

 

Thank you

MAXOBJECTID_not_addingThanks

Whilst MAXOBJECTID now seems to be populating it is adding the same number repeatedly instead of adding '1' in order to generate a unique number in each row i.e. 284, 285, 286 etc.

I tried a Counter in between SQLCreator and FeatereMerger_2 but this did not work.

Userlevel 6
Badge +33

Not sure how legible my workbench is but will hopefully give you an idea of the process.

 

As I already have a FeatureMerger i'm not sure if i can add another one (where?) or adapt the existing one (how?)

 

Turned caching off, it doesn't generate any polygons just the attributes.

 

The VariableSetter is upstream from the VariableSetter is it not?

 

Thank you

If you want to generate new id, place the counter after the FeatureMerger, then an AttributeCreator to create objectid = maxobjectid + _count.

Badge +5

Not sure how legible my workbench is but will hopefully give you an idea of the process.

 

As I already have a FeatureMerger i'm not sure if i can add another one (where?) or adapt the existing one (how?)

 

Turned caching off, it doesn't generate any polygons just the attributes.

 

The VariableSetter is upstream from the VariableSetter is it not?

 

Thank you

Thanks, managed to resolve just with Counter after FeatureMerger

Reply