<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Query where clause type conversion in ArcGIS API for Silverlight Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/query-where-clause-type-conversion/m-p/736299#M18865</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I want to do a type conversion and a concatenation in a query where clause.&amp;nbsp; I have street number as a esriFieldTypeInteger and street name as a esriFieldTypeString.&amp;nbsp; I want to search for "5 Main Street" as a single search term.&amp;nbsp; If the street number were string, I could use this: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CONCAT(street_num, CONCAT(' ', street_name)) = '5 Main Street'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But the numeric field type is causing difficulty.&amp;nbsp; I've tried CAST and CONVERT to varchar, nvarchar, text, but it doesn't work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ted Chapin&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 23 May 2011 18:17:27 GMT</pubDate>
    <dc:creator>TedChapin</dc:creator>
    <dc:date>2011-05-23T18:17:27Z</dc:date>
    <item>
      <title>Query where clause type conversion</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/query-where-clause-type-conversion/m-p/736299#M18865</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I want to do a type conversion and a concatenation in a query where clause.&amp;nbsp; I have street number as a esriFieldTypeInteger and street name as a esriFieldTypeString.&amp;nbsp; I want to search for "5 Main Street" as a single search term.&amp;nbsp; If the street number were string, I could use this: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CONCAT(street_num, CONCAT(' ', street_name)) = '5 Main Street'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But the numeric field type is causing difficulty.&amp;nbsp; I've tried CAST and CONVERT to varchar, nvarchar, text, but it doesn't work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ted Chapin&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 May 2011 18:17:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/query-where-clause-type-conversion/m-p/736299#M18865</guid>
      <dc:creator>TedChapin</dc:creator>
      <dc:date>2011-05-23T18:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: Query where clause type conversion</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/query-where-clause-type-conversion/m-p/736300#M18866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is your Query.Where clause checking against two different fields? If so, I think you need to keep the search fields separate.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Where = Street_Number = 5 and Street_Name = 'Main Street'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
int streetNumber;
string streetName;
query.Where = string.Format("StreetNumber = {0} and Street_Name = '{1}'", streetNumber, streetName);
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:22:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/query-where-clause-type-conversion/m-p/736300#M18866</guid>
      <dc:creator>JenniferNery</dc:creator>
      <dc:date>2021-12-12T07:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: Query where clause type conversion</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/query-where-clause-type-conversion/m-p/736301#M18867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, the address number and street name are in separate fields.&amp;nbsp; But I want to keep my UI googlish with only 1 input box.&amp;nbsp; I actually simplified the query for my post.&amp;nbsp; I search for MBL, owner name, and address with 1 user text box.&amp;nbsp; When the MBL, owner name, street number, and street name fields are all string, it works with this query:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;query.Where = String.Format("UPPER(MBLU) LIKE '%{0}%' OR UPPER(Owner) LIKE '%{0}%' OR UPPER(Co_owner) LIKE '%{0}%' OR CONCAT(Street_Number, CONCAT(' ', Street_Name)) LIKE '%{0}%'", SearchText.Text.ToUpper)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But one town I work with has a numeric field type for the street number.&amp;nbsp; SO, I would like to do something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;query.Where = String.Format("UPPER(MBLU) LIKE '%{0}%' OR UPPER(Owner) LIKE '%{0}%' OR UPPER(Co_owner) LIKE '%{0}%' OR CONCAT(CAST(Street_Number AS varchar()), CONCAT(' ', Street_Name)) LIKE '%{0}%'", SearchText.Text.ToUpper)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But CAST (or at least the varchar data type) doesn't seem to be supported by whatever version of SQL the REST API uses.&amp;nbsp; Neither does CONVERT.&amp;nbsp; The documentation doesn't go into any detail about what SQL statements are allowed.&amp;nbsp; I just guessed about CONCAT and UPPER.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It may be that, in order to keep my search UI to one text box to search all those fields, I will have to modify the table schema to make the street number field a string.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 May 2011 12:02:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/query-where-clause-type-conversion/m-p/736301#M18867</guid>
      <dc:creator>TedChapin</dc:creator>
      <dc:date>2011-05-24T12:02:07Z</dc:date>
    </item>
    <item>
      <title>Re: Query where clause type conversion</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/query-where-clause-type-conversion/m-p/736302#M18868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I don't think UPPER or CONCAT works either. Have you tried doing this query on your web browser from the service's REST endpoint?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I guess what you can do is split the input string and try to determine which can be converted to a number so you can check them against your number fields when you form your where clause.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 May 2011 18:18:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/query-where-clause-type-conversion/m-p/736302#M18868</guid>
      <dc:creator>JenniferNery</dc:creator>
      <dc:date>2011-05-24T18:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: Query where clause type conversion</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/query-where-clause-type-conversion/m-p/736303#M18869</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Those SQL statements work.&amp;nbsp; Try this query:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;UPPER(MBLU) LIKE '%106 LEDGE RD%' OR UPPER(Grantee) LIKE '%106 LEDGE RD%' OR UPPER(Co_grantee) LIKE '%106 LEDGE RD%' OR CONCAT(Street_Number, CONCAT(' ', Street_Name)) LIKE '%106 LEDGE RD%'&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;on this table:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;https://eis.woodardcurran.com/ArcGIS/rest/services/PublicServices/Ogunquit/MapServer/22/query&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wish there was some documentation about what the REST query's where clause supports.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 May 2011 18:49:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/query-where-clause-type-conversion/m-p/736303#M18869</guid>
      <dc:creator>TedChapin</dc:creator>
      <dc:date>2011-05-24T18:49:04Z</dc:date>
    </item>
    <item>
      <title>Re: Query where clause type conversion</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/query-where-clause-type-conversion/m-p/736304#M18870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;According to REST API &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisserver/10.0/apis/rest/query.html"&gt;http://help.arcgis.com/en/arcgisserver/10.0/apis/rest/query.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Any legal SQL where clause operating on the fields in the layer is allowed.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;According to this &lt;/SPAN&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/ms187928.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms187928.aspx&lt;/A&gt;&lt;SPAN&gt;, you can construct a CAST the following way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt; AV_PID = CAST('1069' as INT)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 May 2011 16:46:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/query-where-clause-type-conversion/m-p/736304#M18870</guid>
      <dc:creator>JenniferNery</dc:creator>
      <dc:date>2011-05-25T16:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: Query where clause type conversion</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/query-where-clause-type-conversion/m-p/736305#M18871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, CAST does work.&amp;nbsp; I had been using CAST(street_num AS varchar()), which is a lazy way to convert to string if you don't care about the string's length.&amp;nbsp; In T-SQL the default is 30 if it's not specified.&amp;nbsp; The REST API won't process varchar(), but this works: varchar(5), or whatever length is appropriate.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 May 2011 17:39:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/query-where-clause-type-conversion/m-p/736305#M18871</guid>
      <dc:creator>TedChapin</dc:creator>
      <dc:date>2011-05-25T17:39:26Z</dc:date>
    </item>
  </channel>
</rss>

