LB1

Make Query Table works in Python Window but not as Tool???

Discussion created by LB1 on Jun 25, 2014
Latest reply on Jan 9, 2015 by tbrabant
Hi,

I'm a newbie at coding, so I hope my question is clear.

The below code works perfectly when I run it in the Python Window of 10.1.

But when I make a tool and attach the script, it runs and indicates that the script completed successfully but yet the table is not added to the TOC. Why will it not automatically appear?

Any ideas? I've tried so many things to make the table appear, I can't even remember anymore.

Lonnie




import arcpy, datetime, arcgisscripting, os
from arcpy import env

# Local variables.
tableList = "Database Connections/Database.odc/FWS_WMIS.FWI_INVENTORY_PROJECT;Database Connections/Database.odc/FWS_WMIS.FWI_INVENTORY_SURVEY"
   
fieldList = "FWS_WMIS.FWI_INVENTORY_PROJECT.INV_PROJ_ID 'INVENTORY_PROJECT_ID';FWS_WMIS.FWI_INVENTORY_SURVEY.INV_SURVEY_ID 'INV_SURV_ID';FWS_WMIS.FWI_SURVEY_CREW_FNC(FWS_WMIS.FWI_INVENTORY_SURVEY.INV_SURVEY_ID) 'SURVEY_CREW'"
whereClause = "FWS_WMIS.FWI_INVENTORY_PROJECT.INV_PROJ_ID=FWS_WMIS.FWI_INVENTORY_SURVEY.INV_PROJ_ID AND FWS_WMIS.FWI_INVENTORY_PROJECT.INV_PROJ_ID=17909"
keyField = "FWS_WMIS.FWI_INVENTORY_PROJECT.INV_PROJ_ID"

#Get the current date and time.
now = datetime.datetime.now()

#Use the current time as the name for the layer to produce a unique name for every layer.
lyrName = now
   
# Make Query Table.
arcpy.MakeQueryTable_management(tableList, lyrName,"USE_KEY_FIELDS", keyField, fieldList, whereClause)

Outcomes