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

8700
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
Kathleen_Crombez
Occasional Contributor III

Thanks for taking the time to try to figure it out.

0 Kudos
AnnStark2
New Contributor II

Just wanted to chime in that we are having the same issue with MakeTableView not working in 10.3.1 environments but the same exact script running just fine in 10.2 environment (we store the scripts on a network drive so it is the same script in each instance that is run).  We tried adding the OBJECTID to the table (in this case a SQL View), based on comments in this post,  but that did not solve the problem for us.

Our python statement looks like this

arcpy.MakeTableView_management(UTILITY_BILLING_CUSTOMERS, Utility_Billing_Customers_View, "", "", "OBJECTID OBJECTID VISIBLE NONE;...<many fields here>")

in case that's of interest to anyone.  No WHERE clause is used.

It sounds like a bug and hopefully will be addressed in 10.4.

AlisonGaiser1
Occasional Contributor

Has anyone logged a call with Esri? If so, anyone have a bug number?

We are up and running by adding in the OBJECTID field in our materialized views so not sure what kind of call we would post to Esri Canada?

0 Kudos
Kathleen_Crombez
Occasional Contributor III

This continues to be an issue for us.

We have several scripts that have been written over the years that we either have set to run on scheduled tasks or we run annually during different times of the year.

Most of these scripts now fail at version 10.3.1 due to this error.

ERROR 000358: Invalid expression

This error is occurring on both the MakeTableView and MakeFeatureLayer methods.

All of our tables and layers have OBJECTID fields.

I really hope that someone from ESRI can track the error down and fix it soon. We have already upgraded all our desktop machines to 10.3.1 and are hoping to upgrade our servers in a couple months. But this issue is going to leave us dead in the water if it isn't fixed.

0 Kudos
DanPatterson_Retired
MVP Emeritus

If no one has reported it, there will be no error report.  If one has been filed, then you could ask your tech support for a contact number.

some links

Error reporting for ArcGIS software—Help | ArcGIS for Desktop

then each version of arcmap contains a document like this, so since you are using an older than current release version, chec to see if the error had been reported and solved.  If it isn't on the list, it probably wasn't reported...it is buried in a huge list.. or hasn't been fixed, or it isn't a software error but a user error or procedural difference of opinion.  Here it is anyway\

http://downloads.esri.com/support/downloads/other_/104-IssuesAddressedList.pdf

Kathleen_Crombez
Occasional Contributor III

I found a few bugs had been reported that seemed relevant to this issue.

Both said the issue had been fixed in version 10.4

I just upgraded to 10.4 and am still having this error occur.

These scripts run fine in version 10.2.2

0 Kudos
Waan
by
Occasional Contributor

Hi Kathleen,

Have you found a workaround for this? Did Esri get back to you about a bug report? We are testing an upgrade from 10.1 to 10.3.1 and found a vital script is failing after a MakeTableView (error is actually thrown by a subsequent SelectLayerByAttribute).

Thanks,

-W

0 Kudos
DanPatterson_Retired
MVP Emeritus

On my blog near the top, I have links to the change logs performed in arcmap, if you want to wade through and see if one is mentioned that involves maketableview, this would be the shortest path other than filing a bug error yourself.  Have a look

The ...py... links

0 Kudos
Waan
by
Occasional Contributor

Thanks Dan, I was actually wading through some of them when you replied. While there were some fixes to MakeTableView in 10.3 and 10.4, they seemed to deal with specific issues, e.g. when working on a .csv. I didn't see anything to indicate a broader fix.

I re-opened a ticket with Esri about this issue. For the sake of completeness in this thread, here's my piece of code that bombs ... this is a table and a feature class in a file geodatabase:

wellboretable = workspace + "tbl_wellbores"
wellbores = workspace + "wellbores"
arcpy.MakeTableView_management(wellboretable, "wellboretable_layer")
arcpy.AddJoin_management("wellboretable_layer", "UniqueId", wellbores, "UniqueId", "KEEP_ALL")
arcpy.SelectLayerByAttribute_management("wellboretable_layer", "NEW_SELECTION", "(\"tbl_wellbores.Deviation\" = '' OR \"tbl_wellbores.Deviation\" IS NULL) AND \"wellbores.Length_ft\" >= 3000")

Lest anyone thinks the syntax in the select statement is bad, I used GetCount_management, Exists, ListFields, and CopyRows_management to verify that data existed, the join worked, and the fields were typed accurately. I also tried using single and double quotes instead but still received an error. Interestingly, I noticed GetCount_management would return 0 after a bomb, so I used a CLEAR_SELECTION throughout my testing. To make this even simpler, I tried the following after the join:

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

... which still threw the same ERROR 000358. To be sure, I used a SearchCursor to verify that an OBJECTID of 1 exists in this table view. I emphasize that all of this code works fine in 10.1. I didn't spot anything in 10.3 (or 10.3.1) documentation that the SelectByAttribute syntax or SQL syntax had changed.

I'll see what Esri has to say.

0 Kudos
DanPatterson_Retired
MVP Emeritus

put a print statement after this line to ensure that the paths are correct

wellboretable = workspace + "tbl_wellbores"

I am wondering if a \ is missing before tbl_wellbores

One incarnation won't give you the correct path, the second would produce an error and the 3rd would work and the last is an alternative (then there is the join thing

>>> workspace = r"c:\Temp\path"
>>> workspace + "tbl_wellbores"
'c:\\Temp\\pathtbl_wellbores'
>>> workspace = r"c:\Temp\path\"
Traceback (  File "<interactive input>", line 1
    workspace = r"c:\Temp\path\"
                               ^
SyntaxError: EOL while scanning string literal
>>> workspace = r"c:\Temp\path" + "\tbl_wellbores"
>>> workspace
'c:\\Temp\\path\tbl_wellbores'
>>> workspace = "c:/Temp/path" + "/tbl_wellbores"
>>> workspace
'c:/Temp/path/tbl_wellbores'
>>>
0 Kudos