0

I am attempting to select nulls from an in_memory feature layer using Arcpy's Select_analysis. Code example below, as well as, various iterations of attempts to alter the SQL query with no success.

sql_1 = '"{}_BBL" IS NOT NULL'.format(some_dataset_name)
print(sql_1)
arcpy.Select_analysis("Some_inmemory_layer", "Output_Name", sql_1)

The actual SQL query itself is as follows:

'"E_GIS_20190111_BBL" IS NOT NULL'

The empty output Feature Class yielded when encountering the invald expression error shows that the field name I am referencing is correct (field name matches above used in query in both attrib table and properties>fields tab).

I have tried the following fixes with no success:

'"E_GIS_20190111_BBL" <> NULL'

'"E_GIS_20190111_BBL" != NULL'

Error message received:

arcgisscripting.ExecuteError: ERROR 000358: Invalid expression "E_GIS_20190111_BBL" IS NOT NULL Failed to execute (Select).

  • 1
    Your workspace is set to in_memory? Try: sql_1 = "{0} IS NOT NULL".format(arcpy.AddFieldDelimiters(some_dataset_name,'{0}_BBL'.format(some_dataset_name))) – BERA Jan 30 at 15:43
  • 2
    Try this SQL query instead? "E_GIS_20190111_BBL IS NOT NULL", note it is just double quotes. – Hornbydd Jan 30 at 15:48
  • BERA - Thank you for the reply. I attempted to use your revised sql expression and got back the same invald expression error. Hornbydd - Thank you for the reply. I attempted this, as well, and got back the same invalid expression error – CambrianCatalyst Jan 30 at 16:08
  • 4
    The easiest way to determine the where_clause formatting is to run the command manually. In Geoprocessing, Results, "Copy as Python snippet". Paste the code in a text editor. – klewis Jan 30 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.