Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

formatting SQL expressions in arcpy

$
0
0

I’m trying to use SelectLayerByAttribute to find the last point added to a FC. I figured I could use the objectid field because it’s serial. I wrote the following:

arcpy.SelectLayerByAttribute_management("controller", "NEW_SELECTION", """ "OBJECTID" = (SELECT MAX("OBJECTID") FROM controller) """) 

following the notes on found here

However, I get the following error:

Runtime error Traceback (most recent call last): File “”,
line 1, in File “c:program files
(x86)arcgisdesktop10.2arcpyarcpymanagement.py”, line 6494, in
SelectLayerByAttribute raise e ExecuteError: ERROR 000358: Invalid
expression Failed to execute (SelectLayerByAttribute).

I’m using a Postgres geodatabase and I know all the db’s require slightly different formatting requirements. This one I can’t figure out though.


Viewing all articles
Browse latest Browse all 767

Trending Articles