I have built an app with WxPython to run in Arcmap to search some tables that are already existing in ArcMap as a Python Addin. I have a few fields in this table that will get results just fine and some fields that will get correct results and then no results from the same field with just different search values. My search is a LIKE type query, Ex, if I enter 55 as my search value, my WxPython app will not finish and open the PDF that has the results. If I enter 61 my search will finish and open the PDF with the appropriate data in the report. I do know there are several rows in my table that should be in the 355 search results.
If I run the code in the ArcMap Python window against the table with the 55 value I get the expected results with no problem from the cursor. The only difference that I can see are the variables I am using in the query. If I run it in the ArcMap Python window I am setting the variables manually to make sure the query is good. In the WxPython App I am getting one variable from a selection made from a dropdown for the field "ESN" and the search value is from a text box where the user enters the value, "55".
The examples below are from a script that I am testing in the ArcMap window and then the search that my WxPython App is using. The syntax is all correct so the indentations may be different between the two. My main issue is why can't I get results when I use "55" as my value and I can get results when I search "61" when there are values in the table that should get results when I search LIKE '%55%'. Also this same thing is happening in the Community field when I search LIKE values in there as well.
I have tested several variations and other fields and most everything will return results but I can't see any reason these will not.
Any help would be GREATLY appreciated!!!
Thanks
Chris
Here is the snippet from my manual search that gives me the results I want:
test <SPAN class="operator token">=</SPAN> <SPAN class="string token">'ESN'</SPAN>
<SPAN class="comment token">#Query to retreive data from gisMSAG for GeoSearch...</SPAN>
story <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN>
results<SPAN class="operator token">=</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN>
fields <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'LOW'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'HIGH'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'DIR'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'STREET NAME'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'EOB'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'COMMUNITY'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'ZIP'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'ESN'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'SRNUM'</SPAN><SPAN class="punctuation token">]</SPAN>
story<SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>fields<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN>fc3<SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">[</SPAN>dir<SPAN class="punctuation token">,</SPAN>sname<SPAN class="punctuation token">,</SPAN>low<SPAN class="punctuation token">,</SPAN>high<SPAN class="punctuation token">,</SPAN>com<SPAN class="punctuation token">,</SPAN>eob<SPAN class="punctuation token">,</SPAN>esn<SPAN class="punctuation token">,</SPAN>sr<SPAN class="punctuation token">,</SPAN>zip<SPAN class="punctuation token">,</SPAN>desc<SPAN class="punctuation token">,</SPAN>rem<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN>test<SPAN class="operator token">+</SPAN><SPAN class="string token">" LIKE UPPER('%55%')"</SPAN><SPAN class="punctuation token">,</SPAN>sql_clause<SPAN class="operator token">=</SPAN><SPAN class="punctuation token">(</SPAN>None<SPAN class="punctuation token">,</SPAN><SPAN class="string token">'ORDER BY '</SPAN><SPAN class="operator token">+</SPAN>sname<SPAN class="operator token">+</SPAN><SPAN class="string token">' ASC, '</SPAN><SPAN class="operator token">+</SPAN>low<SPAN class="operator token">+</SPAN><SPAN class="string token">' '</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> cursor5<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> mg <SPAN class="keyword token">in</SPAN> cursor5<SPAN class="punctuation token">:</SPAN>
msagdir <SPAN class="operator token">=</SPAN> mg<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
msagsname <SPAN class="operator token">=</SPAN> mg<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN>
msaglow <SPAN class="operator token">=</SPAN> mg<SPAN class="punctuation token">[</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN>
msaghigh <SPAN class="operator token">=</SPAN> mg<SPAN class="punctuation token">[</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">]</SPAN>
msagcom <SPAN class="operator token">=</SPAN> mg<SPAN class="punctuation token">[</SPAN><SPAN class="number token">4</SPAN><SPAN class="punctuation token">]</SPAN>
msageob <SPAN class="operator token">=</SPAN> mg<SPAN class="punctuation token">[</SPAN><SPAN class="number token">5</SPAN><SPAN class="punctuation token">]</SPAN>
msagesn <SPAN class="operator token">=</SPAN> mg<SPAN class="punctuation token">[</SPAN><SPAN class="number token">6</SPAN><SPAN class="punctuation token">]</SPAN>
msagsr <SPAN class="operator token">=</SPAN> mg<SPAN class="punctuation token">[</SPAN><SPAN class="number token">7</SPAN><SPAN class="punctuation token">]</SPAN>
msagzip <SPAN class="operator token">=</SPAN> mg<SPAN class="punctuation token">[</SPAN><SPAN class="number token">8</SPAN><SPAN class="punctuation token">]</SPAN>
display <SPAN class="operator token">=</SPAN> msaglow<SPAN class="punctuation token">,</SPAN>msaghigh<SPAN class="punctuation token">,</SPAN>msagdir<SPAN class="punctuation token">,</SPAN>msagsname<SPAN class="punctuation token">,</SPAN>msageob<SPAN class="punctuation token">,</SPAN>msagcom<SPAN class="punctuation token">,</SPAN>msagzip<SPAN class="punctuation token">,</SPAN>msagesn<SPAN class="punctuation token">,</SPAN>msagsr
story<SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>display<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> story<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Here is the snipped of the same search from my WxPython App:
story <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN>
results<SPAN class="operator token">=</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN>
fields <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'LOW'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'HIGH'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'DIR'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'STREET NAME'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'EOB'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'COMMUNITY'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'ZIP'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'ESN'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'SRNUM'</SPAN><SPAN class="punctuation token">]</SPAN>
story<SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>fields<SPAN class="punctuation token">)</SPAN>
self<SPAN class="punctuation token">.</SPAN>SBar<SPAN class="punctuation token">.</SPAN>SetStatusText<SPAN class="punctuation token">(</SPAN>str<SPAN class="punctuation token">(</SPAN>selectedfield<SPAN class="operator token">+</SPAN><SPAN class="string token">" "</SPAN><SPAN class="operator token">+</SPAN>searchvalue<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>SearchCursor<SPAN class="punctuation token">(</SPAN>fc3<SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">[</SPAN>dir<SPAN class="punctuation token">,</SPAN>sname<SPAN class="punctuation token">,</SPAN>low<SPAN class="punctuation token">,</SPAN>high<SPAN class="punctuation token">,</SPAN>com<SPAN class="punctuation token">,</SPAN>eob<SPAN class="punctuation token">,</SPAN>esn<SPAN class="punctuation token">,</SPAN>sr<SPAN class="punctuation token">,</SPAN>zip<SPAN class="punctuation token">,</SPAN>desc<SPAN class="punctuation token">,</SPAN>rem<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN>selectedfield<SPAN class="operator token">+</SPAN><SPAN class="string token">" LIKE '%"</SPAN><SPAN class="operator token">+</SPAN>str<SPAN class="punctuation token">(</SPAN>searchvalue<SPAN class="punctuation token">)</SPAN><SPAN class="operator token">+</SPAN><SPAN class="string token">"%'"</SPAN><SPAN class="punctuation token">,</SPAN>sql_clause<SPAN class="operator token">=</SPAN><SPAN class="punctuation token">(</SPAN>None<SPAN class="punctuation token">,</SPAN><SPAN class="string token">'ORDER BY '</SPAN><SPAN class="operator token">+</SPAN>sname<SPAN class="operator token">+</SPAN><SPAN class="string token">' ASC, '</SPAN><SPAN class="operator token">+</SPAN>low<SPAN class="operator token">+</SPAN><SPAN class="string token">' '</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> cursor5<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> mg <SPAN class="keyword token">in</SPAN> cursor5<SPAN class="punctuation token">:</SPAN>
msagdir <SPAN class="operator token">=</SPAN> mg<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
msagsname <SPAN class="operator token">=</SPAN> mg<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN>
msaglow <SPAN class="operator token">=</SPAN> mg<SPAN class="punctuation token">[</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN>
msaghigh <SPAN class="operator token">=</SPAN> mg<SPAN class="punctuation token">[</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">]</SPAN>
msagcom <SPAN class="operator token">=</SPAN> mg<SPAN class="punctuation token">[</SPAN><SPAN class="number token">4</SPAN><SPAN class="punctuation token">]</SPAN>
msageob <SPAN class="operator token">=</SPAN> mg<SPAN class="punctuation token">[</SPAN><SPAN class="number token">5</SPAN><SPAN class="punctuation token">]</SPAN>
msagesn <SPAN class="operator token">=</SPAN> mg<SPAN class="punctuation token">[</SPAN><SPAN class="number token">6</SPAN><SPAN class="punctuation token">]</SPAN>
msagsr <SPAN class="operator token">=</SPAN> mg<SPAN class="punctuation token">[</SPAN><SPAN class="number token">7</SPAN><SPAN class="punctuation token">]</SPAN>
msagzip <SPAN class="operator token">=</SPAN> mg<SPAN class="punctuation token">[</SPAN><SPAN class="number token">8</SPAN><SPAN class="punctuation token">]</SPAN>
display <SPAN class="operator token">=</SPAN> msaglow<SPAN class="punctuation token">,</SPAN>msaghigh<SPAN class="punctuation token">,</SPAN>msagdir<SPAN class="punctuation token">,</SPAN>msagsname<SPAN class="punctuation token">,</SPAN>msageob<SPAN class="punctuation token">,</SPAN>msagcom<SPAN class="punctuation token">,</SPAN>msagzip<SPAN class="punctuation token">,</SPAN>msagesn<SPAN class="punctuation token">,</SPAN>msagsr
story<SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>display<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> story<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>