MakeTableView in python script fails after Update to 10.3.1 on 64 bit OS

8685
26
12-23-2015 04:15 PM
JessicaFraver1
New Contributor III

Hi,

Since upgrading ArcGIS Desktop from 10.2.2 to 10.3.1, we receive a new error in our python scripts that use MakeTableView -      arcpy.MakeTableView_management(sourcewrkspc + sourcedata, "in_memory\\" + layer, whereclause).

The script error is as follows:

ERROR 000358: Invalid expression

Failed to execute (MakeTableView).

Further tests revealed that the arcpy.MakeTableView does not work on tables with no OBJECTID. Registering the table with the database generates an OBJECTID and gets rid of the error, but this is not an option for some of our tables.

Has anyone experienced this problem with 10.3.1 and know why this error happens? Is there a fix besides creating a workaround to add an OBJECTID?

Thank you!

0 Kudos
26 Replies
Waan
by
Occasional Contributor

Turns out it was the quotes in the selection syntax. This change occurred sometime between 10.1 and 10.3.1, though Esri says I was writing bad queries all along as double-quotes are a
no-no … though it looks like double-quotes are only problematic when used on joined fields in various selection queries (including definition queries—this was also causing problems in some 10.1 .mxds once we upgraded 10.3.1). I’ve removed them from my arcpy habits altogether.

This worked at 10.1 but doesn't work at 10.3.1:

arcpy.SelectLayerByAttribute_management("wellboretable_layer", "NEW_SELECTION", "\"tbl_wellbores.OBJECTID\" = 1")

This does:

arcpy.SelectLayerByAttribute_management("wellboretable_layer", "NEW_SELECTION", "tbl_wellbores.OBJECTID = 1")

ScottDavis
Occasional Contributor

I was able to workaround this bug by copying the table to a temp GDB before calling MakeTableView.

Brownschuh
Occasional Contributor II

While this works, it kind of defeats the purpose of having all geoprocessing parts of a script run 'in memory' (which is what I'm trying to accomplish)

0 Kudos
Jean-ChristopheSAINTE
New Contributor

Hello.

I have the same issue with a model builder using MakeTableView that was running perfectly from 9.2 to 10.1. Now I'm using 10.3 and it doesn't work anymore. The same error code is returned (according to SQL statement that is however empty !). I tried several things to find where the error could be (remove strings with quotes inside fields values, apply a where clause to get all records 1=1, export table to text file and use this...). Finally the model builder works fine without any changes if the table used for MakeTableView contains less than 101 records... Is there a "max records parameter" somewhere that could have been changed or applied in the 10.3 version ?

Have a nice day !

0 Kudos
PhilLarkin1
Occasional Contributor III

This is fixed in 10.4. I tested against a non-sde table (no object ids). My situation is similar to Jessica Fraver's and have resorted to Scott Davis's solution in the past.

There are at least two bug reports that are possibly associated. 

BUG-000088142: Executing the Make Table View tool fails, and return.. 

BUG-000090109: The Make Table View tool fails with "ERROR 000358: I.. 

LeeAllen
Occasional Contributor

Seems to be fixed in 10.4.1. This post was very helpful, I ended up skipping 10.3 and going to 10.4.1 because I have several scripts that broke at 10.3.

Brownschuh
Occasional Contributor II

I just want to say I'm glad I found this thread.  Was having trouble with my script on my desktop machine running 10.3.1; kept getting a 000358 error even though I didn't even have an expression ... it was blank.  Out of frustration I decided to upgrade to 10.5, ran the script without making a single change and it worked.

0 Kudos