LIKE operator with the Query Attributes task failed

289
9
12-09-2021 04:00 AM
Chapin
by
New Contributor III

I need to find all featuress in the zone_code field that begin with N
I entered the sql as zone_code LIKE 'N%' Pro remind me with a wrong expression, this sql i can succeed with database query statement, but failed in pro.
In addition, I entered zone_code LIKE 'N0%' also failed, only zone_code LIKE 'N01%' can be executed successfully. Why is that?

Chapin_0-1639050038028.png

Chapin_1-1639050287478.png

Chapin_2-1639050310051.png

Chapin_3-1639050325714.png

 

 

 

0 Kudos
9 Replies
Chapin
by
New Contributor III

Chapin_0-1639052649384.png

 

Chapin_1-1639052674803.png

Why is it that all other letters work but N% is invalid?

 

0 Kudos
GintautasKmieliauskas
Regular Contributor II

Hi,

What kind of database do you use for querying?

On enterprise database  and FGDB it works, on shape file doesn't.

P.s. After restart of ArcGIS Pro it works on shapefile too.

0 Kudos
Chapin
by
New Contributor III

i use enterprise database.I don't know why only this N% is not working

0 Kudos
GintautasKmieliauskas
Regular Contributor II

You can add one line of code to your add-in to check what is your database wildcard symbol is.

 string wildChar = geodatabase.GetSQLSyntax().GetSpecialCharacter(SQLSpecialCharacter.WildcardManyMatch);

 

0 Kudos
Chapin
by
New Contributor III

Chapin_0-1639060723240.png

is %.

sir, I just did the test
The layer object I query is created by new featureservice url, if I add the current layer directly to the database table for like %N query it is valid.
Maybe the layer object created by featureservice url does not support this query.

0 Kudos
ABishop
Regular Contributor III

Hello Chapin,

Have you tried other like wildcards?  Here is a technical support article:

https://support.esri.com/en/technical-article/000010066 

Amanda Bishop, GISP
0 Kudos
Chapin
by
New Contributor III

thanks.maybe featureservice layer does not support this like query.

0 Kudos
jcarlson
MVP Honored Contributor

What does Pro show you when you click "View Details" on the error response?

Also, what database is your SDE in? Postgres? Oracle? MSSQL?

- Josh Carlson
Kendall County GIS
0 Kudos
Chapin
by
New Contributor III

sir.

my database is SQLServer.

But the Layer object I query is created by new featureservice url.

According to the test result, the featureservice layer seems to have some problems with this kind of query, some layers are valid, some will prompt the sql statement is invalid.

0 Kudos