1

I have two processes in model builder:

  1. Iterate over a "ID_SPATIAL" field values = creating a subset of original feature class (and agregating using Frequency tool)
  2. Creating a different subset using a "Code" field from the original feature class by SQL query

What I need is to use the values from "Code" field within the first subset as an input to SQL query. Model looks like this:

Model

My SQL query could look like this:

SELECT * FROM INPUT2 WHERE Code IN (SELECT Code FROM %ID_freq list%)

The attribute table of objects looks like this: enter image description here

I have spent last day wondering about this problem. How can I transfer values from field of another process into SQL query?


I don't have a solution yet... but I succeded to make a procedure using a submodels with Merge tool and Collect Values tool of model builder. This is very programming nasty, but since I haven't found a solution it helped. THe problem is, that this is very very time consuming procedure, and I have to run it over and over again after an hour when ArcMap depletes its inner memory.

Submodel: for each ID_SPATIAL this iterates "Code" field and back query the data (A02_108_not_null_codes) "Code" field for each one. Afterwards, it passes selected features to Merge tool (overall model).

Overall model: merge the results in one layer enter image description here

This should serve as a typo finder. Once in a map, I can see if some codes were mistyped because these features lay apart from the rest of particular ID_SPATIAL region: enter image description here

  • a bit confused what you are trying to accomplish...but when you are writing the SQL expression maybe "Add to current selection" or "Select from current selection" is what you need to do – ziggy Mar 20 '16 at 16:53
  • I want to see if there are features that have "Code" equal to set of "Code" values present in current "ID_SPATIAL" subset (so that these features have another ID_SPATIAL). Does this help? Simply: 1) chose all "Code" values from a particular ID_SPATIAL set of features and 2) back query original data using these "Codes". Afterwards if there was a typo in "Codes" I can see that by Zoom to layer. – Martin Hroch Mar 21 '16 at 20:23
  • Here is a Python tool/script that might help, KeyFileSelect. arcgis.com/home/item.html?id=e638afe0695a4ad38388cb8d9b350446 – klewis Mar 21 '16 at 21:18
  • Thank you. I am not familiar with Python... yet I've started playing with her. Once I have a little time, I wll definitle look at the script. I just wonder why there is no so simple solution as in common querying in Select within an attribute table: select * where CODE IN(1,2,3,4)... – Martin Hroch Mar 23 '16 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.