makeQueryTable fails to execute

697
2
10-31-2013 04:45 AM
DaveTaylor
New Contributor
I had this working on my local computer but when switching it over to the server it is failing with the following error:

Failed to execute. Parameters are not valid.
ERROR 000793: Invalid data element type
ERROR 000840: The value is not a Raster Layer.
Failed to execute (MakeQueryTable).

I think is has something to do with the OLE DB connection...when I open the connection in arcCatalog it takes a longgggg time to open. Maybe it is timing out in the script and thus that is why it is failing? I have included my code below too.

    tableList = ["DATABASE CONNECTIONS/prod.odc/sales"]
    fieldList = ["sales.id",'id']
    whereClause = "sales.CREATED_DATE between to_date(sysdate, 'DD-MON-YYYY') AND SYSDATE"
    keyField = "sales.id"
    lyrName = "live_sales"
   
    #Create the spatial reference for the output layer.
    sr = arcpy.SpatialReference("WGS 1984 UTM Zone 12N")
    # Create a query layer
    arcpy.MakeQueryTable_management(tableList, lyrName,"USE_KEY_FIELDS", keyField, fieldList, whereClause)
     # save the created query layer
    arcpy.SaveToLayerFile_management(lyrName,"I:/sales.lyr", "ABSOLUTE")
# Print the total rows
    print arcpy.GetCount_management(lyrName)


Thanks in advance!
Tags (2)
0 Kudos
2 Replies
MattSayler
Occasional Contributor II
Might be your fieldList variable. Looking at the docs, I think that should be a list of lists.
fieldList = [["sales.id",'id']]


Also: http://forums.arcgis.com/threads/48475-Please-read-How-to-post-Python-code
0 Kudos
DaveTaylor
New Contributor
sorry about the code...here it is...I tried changing fieldList too and that didnt work either:

tableList = ["DATABASE CONNECTIONS/prod.odc/sales"]
fieldList = ["sales.id",'id']
whereClause = "sales.CREATED_DATE between to_date(sysdate, 'DD-MON-YYYY') AND SYSDATE"
keyField = "sales.id"
lyrName = "live_sales"

#Create the spatial reference for the output layer.
sr = arcpy.SpatialReference("WGS 1984 UTM Zone 12N")
# Create a query layer
arcpy.MakeQueryTable_management(tableList, lyrName,"USE_KEY_FIELDS", keyField, fieldList, whereClause)
# save the created query layer
arcpy.SaveToLayerFile_management(lyrName,"I:/sales.lyr", "ABSOLUTE")
# Print the total rows
print arcpy.GetCount_management(lyrName)
0 Kudos