Select to view content in your preferred language

Help with SQL query in Enhanced Search Widget

1677
7
09-09-2014 11:26 AM
Juan-CarlosTorres
New Contributor

I am trying to modify the input value in the Enhanced Search Widget using SQL. I have tested the SQL expression in the ArcMap field calculator and it works but it fails inside the Enhanced Search Widget.

I have a field called MapTaxlot where the values have random spaces. Some of the values have 1, 2, o 3 spaces.
I want the users to be able to type the field value with spaces and modify the input value to eliminate the spaces and query a field where the values have no spaces.
The reason for this is because when we try to use field values with spaces the query fails.

The SQL query to eliminate the spaces is: replace([MapTaxlot]," ", "")
When I combine the above SQL query with the value input in the Enhanced Search Widget it doesn't return a result.
Here is my combined query:

<expression alias="Taxlot" textsearchlabel="Enter the taxlot number below"> <values> <value>Taxlot_Num like ('%replace([value," ", "")%')</value> </values> </expression>

I hope Robert or somebody else could give a clue about what is happening. Thank you.

0 Kudos
7 Replies
JeffWard
Regular Contributor II

You need a closing bracket on [value

Taxlot_Num like ('%replace([value]," ", "")%')

Jeff Ward
Summit County, Utah
0 Kudos
JeffWard
Regular Contributor II

On second thought, this is probably better:

Taxlot_Num like replace('%[value]%',' ', '')

Jeff Ward
Summit County, Utah
0 Kudos
Juan-CarlosTorres
New Contributor

Thank you Jeff.

The first one executes but it doesn't return anything.

The second one gives an error message.

I am pretty sure is the syntax because I am able to eliminate the empty spaces using the query in the field calculator.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Juan,

   I believe the issue you are running into is because Flex uses Replace as a keyword Just like SQL does and that is a conflict. I will have to do some verifying but I think I have looked at this exact situation before for another forum question.

Robert

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Juan,

   So the issue is ArcGIS Server does not support the SQL syntax. You can test this by attempting the query that you have working in ArcMap and trying to use that in your Map Service REST endpoint form.

Example:

http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Louisville/LOJIC_LandRecords_Louisville/M...

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Juan,

   The only way I know to get around this is to change the source code to doe the REPLACE in Flex instead of trying to pass it to the server to do. Let me know if you have the ability to recompile the source and I will point you in the right direction.

0 Kudos
Juan-CarlosTorres
New Contributor

Thank you Robert,

I am currently using the compiled version of your widget and the ArcGIS Viewer for Flex.

I have no flex compiler available

0 Kudos