Query Task "Where" syntax
I would like to use an "AND" type of function in the Query Task "Where" field to combine first and last name fields. Assuming I have field names of "LAST_NAME" and "FIRST_NAME", if I were doing this with a SQL Server command it would be something like:
WHERE (LAST_NAME = 'Smith') AND (FIRST_NAME = 'John')
In the case of the workflow, I have variables for the first and last names, and I can get them to work individually by using a syntax in the form of:
"LAST_NAME = '" + lastName.ToString() + "'"
"FIRST_NAME = '" + firstName.ToString() + "'"
Using the work "AND" isn't allowed. I can enter a command using "+" or "&", but when the workflow gets to the Query Task it fails. For example: "LAST_NAME = '" + lastName.ToString() + "'" & "FIRST_NAME = '" + firstName.ToString() + "'"
Is it possible to use a Where clause in work flow that would duplicate what I can do in SQL?
-
I think what you want is:
"LAST_NAME = ('" + lastName.ToString() + "') AND FIRST_NAME = ("' + firstName.ToString() + "')"
In the end, this is all a sting representing the where clause.
Cheers,
Chris.
0 -
Thanks Chris. Small typo in your suggestion (quote and single quote nesting) but this string worked:
"LAST_NAME = ('" + lastName.ToString() + "') AND FIRST_NAME = ('" + firstName.ToString() + "')"
0 -
Hi Steven,
Good to see you got it work!
I have a question regarding to query non-spatial database tables.
What is the Query Task Url value if I were to query a MS SQL database table? Were you querying a non-spatial database?
Thanks!!
Alex
0 -
The query task acess a ArcGIS Server Map Server service endpoint and communicates using REST. That is why the Activity is located in the ArcGIS server section - it is the ArcGIS Server service that translates this query into a SQL statement which it fires against the geodatabase.
You can't use the activity to query directly on a SQL database neither a non-ArcGIS Server services.
- Sune
0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
4 Kommentare