ArcGIS Pro 3.1.1
For cases where we would rather use SQL than Python or Arcade, is there a way to generate a value using a SQL expression -- that would be returned back to the Field Calculator geoprocessing tool?
For example, if I already have a complex SQL CASE expression written from a different use case, I don't want to re-write it in Python or Arcade. I'd rather just use the SQL as-is instead, to save time and avoid mistakes.
I'm aware that it's possible to create a SQL database view, join it to the FC attribute table, and do a field calculation to bring in the joined field value. But that's pretty cumbersome for a one-off calculation. So I'm wondering if there's a way to use the SQL expression directly in a Python or Arcade field calculation instead.
Related ideas:
Interestingly, SQL is an option when using the field calculator on a hosted feature service.
For file geodatabase feature classes, I'd recommend taking a look at the "where_clause" and "sql_clause" parameters on the UpdateCursor. This might enable your desired workflow.
You could use ArcSDESQLExecute to query your data, format into a dictionary, then use an update cursor or calculate field to update the values by looking them up in your dictionary.