[GIS] Making query layer with query parameters from generated values using ArcGIS ModelBuilder

arcgis-desktopmodelbuilderquery-layer

I want to join a relationship table (same database, not in SDE) to an ArcSDE feature class to display only needed features. This has to be done multiple times according to every row (value) of an other table (same database, not in SDE too).

The first step works, but I have to make a query layer first as it looks like I can't make joins with tables not in the SDE.

I do not want to create ~500 query layers (for the joins), so I'm trying to use ModelBuilder to create the query layers (and maybe also to make the joins in the future).

The figure below shows the model that I've created so far (at the moment I don't know if this approach would generally work/do its job).

enter image description here

I want to use the value catid to perform the query in the Make Query Layer (2).

How should/could I do that?

enter image description here

Here some pseudo things:

table a; -- contains some categories 
table b; -- =m:n relationship table for "a" and "c"
feature class c;
table d_*; --contains all data from "b" related to a single category (row) of "a"


foreach row in a
{
 create table d_*;
}

In psql this would be kind of simple, but I need this done on the ArcGIS level as the join of the feature class relates on this.

I was also thinking about python, because using a programming language this would also be kind of simple — but I have no idea about python and I thought I could avoid scripting.

Best Answer

I'm not sure if there's anything wrong with the text of the query itself, but, to avoid ModelBuilder freaking out on you, you'll need to set catid as a prerequisite to the Make Query Layer step.

If you set up a query or other operation in ModelBuilder that is dependent on a variable generated within the model itself, ModelBuilder will usually try to evaluate the dependent step before evaluating the value of the variable itself.

Related Question