Where clause not working in 10.1 with Copy Features / Copy Rows

1862
5
06-14-2013 10:21 AM
AnthonyVandrunen
New Contributor
We are using scripts and workflows that use the Create Table View / Create Feature Layer with a where clause specified. These functions seem to work (i.e. the correct subsets are shown in ArcMap), but when we try to use Copy Rows / Copy Features, it appears that the where clause is not being observed (i.e. all the records in the original data are copied).

The issue showed up when we tried the scripts on our 10.1 machines (Python 2.7), but it's working fine on our 10.0 machines (Python 2.6). Does anyone know (or can guess) what is going on here? I've looked, but I haven't seen any documented changes between 10.0 and 10.1 as far as how views behave or how the copy functions work.

Thanks.
0 Kudos
5 Replies
DaleHoneycutt
Occasional Contributor III
When executing Copy Features/Copy Rows, you're using the layer as input, not the dataset on disk (pathname to the dataset), correct?

A quick test here shows that Copy Features is honoring layer selections.
0 Kudos
AnthonyVandrunen
New Contributor
Yes, the layer is being used.

The script actually works in 10.1 when the source data (that the view/layer is based on) is coming from a personal GDB; however, when using an SDE connection the copy fails as described. We have also run through the gamut of field enclosures (assuming SDE is the issue), but again, this is working fine in 10.0.
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Hi Anthony,

Have you tested this outside of your script?  Can you post your script?  If copying/pasting the code, don't forget to wrap it in CODE tags using the "#" symbol.
0 Kudos
AnthonyVandrunen
New Contributor
The code is very simple: excluding setup (e.g. defining data input/output), all that's left are the basic calls below. Note that the output destination is always a personal geodatabase.
arcpy.MakeTableView_management( table, view, "MUNICIPALITY_NAME='CITY OF OTTAWA'", "", fieldInfo )   
arcpy.CopyRows_management( view, dataset )


Similarly, using ArcMap 10.1, we can create a proper feature layer with the toolbox (which creates the layer subset with a definition query based on the SDE layer). But when we use the Copy Features tool, all of the records are copied.

I have not played around with the workspace parameter -- could this cause issues?
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Try running the Make Table View and Copy Rows tool outside of your script.  Are you able to reproduce the same issue?  Is the issue reproducible if these tools are executed on a different table?
0 Kudos