I am trying to add a where clause into a arcpy.da.SearchCursor statement, and I keep receiving a 'An expected Field was not found or could not be retrieved properly' error with this code:
where_expression <SPAN class="operator token">=</SPAN> <SPAN class="string token">' "FIELD2" = "CODE1" or "FIELD2" = "CODE2" '</SPAN>
search_feats <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN>f<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">:</SPAN>f<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">for</SPAN> f <SPAN class="keyword token">in</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN>table<SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"FIELD1"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"FIELD2"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"FIELD3"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> where_expression<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>UpdateCursor<SPAN class="punctuation token">(</SPAN>New_Table<SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"NT_FIELD_1"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"NT_FIELD_3"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> upd_cur<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> upd_row <SPAN class="keyword token">in</SPAN> upd_cur<SPAN class="punctuation token">:</SPAN>
upd_row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> search_feats<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN>upd_row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN>
upd_cur<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>upd_row<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">del</SPAN> upd_cur<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>I believe this error is falling on the where clause, as if I exclude the clause from search_feats, the code runs without error. I have used a where clause successfully in this structure in the past, but not with a text field such as FIELD2 here.
Any tips or suggestions would be much appreciated. I have tried many different variations of syntax with no luck yet.
I have verified that the fields exist in the table, have been typed correctly, and do not have any locks.