Quantcast
Channel: Forums - Geoprocessing
Viewing all articles
Browse latest Browse all 1952

Create Query Layer Tool Output Object Not Found or Recognized

$
0
0
ArcGIS 10.1 SP1. ArcSDE 10.1, SQL Server 2008 R2

I have been trying to use the Make Query Layer Tool to create a table view from SDE tables (_VM) in SQL Server 2008 R2 and save the table by a number of export methods with limited success. I have been unsuccessful in saving the information through either the tools, modelbuilder, python window or arcpy (external python). Only manual export is working.

The tool "make query layer" ran from within ArcMap will create the proper table from the SDE/SQL Server 2008R2 query and tables, however, it is not possible to export this Table_View layer using export Table to Table or CopyRows or Table to Geodatabase as shown in the help literature. The ONLY method to export the information has been in the Table of Contents (TOC), through export from the table.


Delving a little deeper I tried to get a little infomration on this object and it appears to contain part of the SQL/SDE connection string as part of it's object as several tools have indicated a .name of "SEKI_HazardTrees.DBO.%HazTree" when the original given name is HazTree only (SEKI_HazardTrees is the name of the SQL/SDE database). I also receive this name when I run arcpy.describe on the object and return a path of the sde connection string.

desc.name = SEKI_HazardTrees.DBO.%HazTree
desc.dataType = TableView
desc.nameString = HazTree
desc.path = Z:\Projects\HazardTrees\inpsekigistest_HazardTrees.sde ( the path of the SQL database)


The error received is very general and similar between failing tools:

Failed to convert SEKI_HazardTrees.DBO.%HazTree. ERROR 999999: Error executing function.
Failed to execute (CopyRows).

or

Cannot open HazTree (the Table View - in arcpy)

I have tried to override the tool from including the SEKI_HazardTrees to it's name by setting up the scratch and normal workspaces to no avail.

IF you have a working python .py example of this (not from the ESRI site that does not work) please post. I have tried all the versions posted by ESRI.

Thanks
Kevin






I'm including my code here for what its worth, but since the stand-alone tools couldn't work I wouldn't expect the arcpy gp tools to work any better (although sometimes they do).



python code
Code:

#Import system modules
import arcpy

arcpy.env.overwriteOutput = True

# Set data path also tried removing the r and change / to //
workspace = r"Z:/Projects/HazardTrees/Results.gdb"
intable = r"Z:/Projects/HazardTrees/Results.gdb/Veg_HazardTreeSurvey_tbl"

inpsekigistest_HazardTrees_sde = r"Z:/Projects/HazardTrees/inpsekigistest_HazardTrees.sde"

arcpy.env.workspace = workspace
arcpy.env.scratch = workspace

# Create the Query Layer and return the Table-View name for verification
test = arcpy.MakeQueryLayer_management(inpsekigistest_HazardTrees_sde, "HazTree", "SELECT * from SEKI_HazardTrees.dbo.Veg_HazardTreeSurvey_tbl_VW", "OBJECTID", "", "", "").getOutput(0)
# Get the properties of the Query Layer if possible
objMQ = arcpy.Describe(test)
print objMQ.name
print objMQ.dataType
print objMQ.nameString
print objMQ.path
print test

# Get column count - note that if the MakequeryLayer function fails, then an empty table with only the schema will be produced.
# However, we have tested this and copied the SQL query and parameters from ArcMap tools for which we were successful generating the Table View so this should be ok

#print int(arcpy.GetCount_management(test).getOutput(0))  # doesn't work
#print int(arcpy.GetCount_management("HazTree").getOutput(0)) # doesn't work

#arcpy.CopyRows_management(test, r"Z:/Projects/HazardTrees/hz002.dbf")  # doesn't work Error 99999
#arcpy.CopyRows_management(test, "Z://Projects//HazardTrees//hz002.dbf")  # doesn't work Error 99999


Viewing all articles
Browse latest Browse all 1952

Trending Articles