You are viewing limited content. For full access, please sign in.

Question

Question

Wildcard Syntax with Workflow Custom Query

asked on January 3, 2014 Show version history

Hello,

 

I found an article on the forums which suggests to use a custom query if you need to use a wildcard. I have been going around in circles trying to get this to work. I am using an ODBC connection to a SQL database. Can you please show me the correct syntax for using the '%' ?

 

Here is what I am using currently:

 

 SELECT  "ESAINHSH"."CM_ATTACH_KEY"
 FROM   "EDENLive"."dbo"."ESAINHSH" "ESAINHSH"
 WHERE "ESAINHSH"."INV_NO" LIKE '?%'

 

Note: I have tried this syntax already: ?%, ?'%', '?'%

 

Thanks!!

0 0

Answer

APPROVED ANSWER SELECTED ANSWER
replied on January 3, 2014 Show version history

You would use just the ? in the query and include % in the parameter value.

 

If you are using a token, lets say 'Initiator', the parameter value would look like:

 

%(Initiator)%

1 0
replied on January 3, 2014 Show version history

Bingo. 

 

I am telling myself that I tried this already, but apparently I didn't. Ha ha

 

Also, it would be in the parameters field of the custom query:

%([MyFieldData])%

 

With the syntax:

WHERE table1.fieldvalue LIKE ?

 

Thank you Ed!

0 0
replied on January 3, 2014

I actually had a typo there. It should be %(Token)% or something like that.

Replies

replied on January 3, 2014

The wild card for a single character is an underscore. There is no need to follow a single character operator with the one or more character operator (%). This accomplishes the same as just a one or more operator.

 

FYI: only string values should be in quotes, not table names.

 

SELECT CM_ATTACH_KEY

FROM ESAINHSH

WHERE INV_NO LIKE '1234_'

 

Where CM_ATTACH_KEY and INV_NO are columns and ESAINHSH is your table.

1 0
replied on January 3, 2014

thanks for the response!

 

I do need it to be the "%" operator. I need one or more characters.

The code comes over form Crystal Reports with the quotes. I have had no issues yet, but good suggestion.

 

 

0 0
replied on January 3, 2014

Not sure where you are going with your '?%' You are asking SQL to show you anything that starts with a ? and then has anything afterwards.

 

% is a substitute for 0 or more characters.

 

so if your list was 

 

1

2

3

?4

5

?6

 

you would get ?4 and ?6 with that above query.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.