1

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)\arcgis\desktop10.2\arcpy\arcpy\management.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.

1 Answer 1

2

Field names aren't escaped as far as I know in Postgres. Try

 'OBJECTID = (SELECT MAX(OBJECTID) FROM controller)'

as your where clause.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.