Make Query Table error

391
4
07-25-2011 01:53 PM
ChristopherBlinn1
Occasional Contributor III
Hello,

I have made a very extensive model in ModelBuilder that keeps getting a 999999 error when trying to run a "Make Query Table" tool.  The message dialogue says it has trouble processing a certain, below is the python script of where the error occurs:

# Process: Make Query Table...
gp.MakeQueryTable_management("'W:\\JointDepartments\\Tyler\\Model_Test\\New Personal Geodatabase.mdb\\PropMast'", QueryTable, "USE_KEY_FIELDS", "PropMast.OBJECTID", "PropMast.parcel_code PropMast.parcel_code;PropMast.property_use_code 
...
...
...
PropMast._bedroom_units;PropMast._bedroom_units_1 PropMast._bedroom_units_1;PropMast._or_more_units 


I am not sure why this field is causing the error.

Below is the error message:

Start Time: Mon Jul 25 16:49:01 2011
ERROR 999999: Error executing function.
Syntax error in query expression 'PropMast._bedroom_units'.
Failed to execute (Make Query Table).
End Time: Mon Jul 25 16:49:01 2011 (Elapsed Time: 0.00 seconds)

Any help is appreciated!
0 Kudos
4 Replies
ChristopherBlinn1
Occasional Contributor III
Fortunately, I was able to solve this issue.

Instead of using the Make Query tool, I was able to use another tool, Create Feature Layer, which allowed me to select feature attribute data within the layer and the model is successfully running.
0 Kudos
ChrisSnyder
Regular Contributor III
Not sure what the problem was, but MakeQueryTable is more suited to complex queries involving multiple tables.
0 Kudos
ChristopherBlinn1
Occasional Contributor III
When I create the Query Table, the next step in the model is to select records based on their attribute information.  When the model reaches this step it displays an error and states that there are too few selections, meaning it cannot make a selection.  However, when I make a feature layer it does work.
0 Kudos
ChrisSnyder
Regular Contributor III
If it helps, here is a code snipit. Sorry I know it's pretty cryptic. If you only have a single input table, then the MakeFeatureLayer (or makeTableView) tool would be most appropriate. The added complexity of MakeQueryTable is only "worth it" if you are relating/joining multiple tables. The code below joins two tables to an input FC table and then outputs a feature layer that is the spatial result of the tabular queries.

queryExp = "question_1_fma_summary.RMU_ID = rmu_polyid.RMU_ID AND rmu_polyid.RMU_POLYID = rmus_we_care_about.RMU_POLYID AND\
rmus_we_care_about.MM_POL_LBL = 'marginal' AND (\
(rmus_we_care_about.HCPUNIT_NM in ('S-COAST','COLUMBIA') AND question_1_fma_summary.COMPSOLD_DATE >= 20000101) OR\
(rmus_we_care_about.HCPUNIT_NM = 'STRAITS' AND question_1_fma_summary.COMPSOLD_DATE >= 20010501) OR\
(rmus_we_care_about.HCPUNIT_NM = 'OESF' AND question_1_fma_summary.COMPSOLD_DATE >= 20020501) OR\
(rmus_we_care_about.HCPUNIT_NM = 'N-PUGET' AND question_1_fma_summary.COMPSOLD_DATE >= 20011101))"
gp.MakeQueryTable_management(question1FmaSummaryTbl + ";" + rmuPolyIdTbl + ";" + rmusWeCareAboutFC, featureLayerFL, "ADD_VIRTUAL_KEY_FIELD", "", "", queryExp)
0 Kudos