cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Use of LOWER Operator in wt.query.SearchCondition

BenPerry
15-Moonstone

Use of LOWER Operator in wt.query.SearchCondition

I am new to QuerySpec and SearchCondition. I have an SQL query that uses the LOWER() operator. Is it possible to use that operator in the wt.query.SearchCondition?

I have an array of usernames, but they are all in lowercase. I wish to query the database with the usernames, but in the database, they are stored as mixed case. Thus sometimes I don't get a result.

SQL:

select name,email from wtuser where lower(name) in ('ben.perry','otheruser1','otheruser2')

Results:

ben.perry ben.perry@company.com

otherUSER1 <email>

OtherUser2 <email>

wt.query.SearchCondition:

(this is a portion of the code in a FOR loop):

wt.query.SearchCondition(wt.org.WTUser.class,wt.org.WTUser.NAME,wt.query.SearchCondition.LIKE,userArray[z])

Results:

ben.perry ben.perry@company.com

<the other users aren't found because userArray[] contains only lowercase characters>

ACCEPTED SOLUTION

Accepted Solutions
BenPerry
15-Moonstone
(To:BenPerry)

I opened a ticket and Mayur @ PTC helped with this.

From JavaDoc:
public SearchCondition(Class targetClass,String anAttribute,String value,boolean caseSensitive) throws QueryException

Therefore, add the false argument to the method at the end.

Correct:

wt.query.SearchCondition(wt.org.WTUser.class,wt.org.WTUser.NAME,wt.query.SearchCondition.LIKE,userArray[z],false)

(Original):

wt.query.SearchCondition(wt.org.WTUser.class,wt.org.WTUser.NAME,wt.query.SearchCondition.LIKE,userArray[z])

View solution in original post

1 REPLY 1
BenPerry
15-Moonstone
(To:BenPerry)

I opened a ticket and Mayur @ PTC helped with this.

From JavaDoc:
public SearchCondition(Class targetClass,String anAttribute,String value,boolean caseSensitive) throws QueryException

Therefore, add the false argument to the method at the end.

Correct:

wt.query.SearchCondition(wt.org.WTUser.class,wt.org.WTUser.NAME,wt.query.SearchCondition.LIKE,userArray[z],false)

(Original):

wt.query.SearchCondition(wt.org.WTUser.class,wt.org.WTUser.NAME,wt.query.SearchCondition.LIKE,userArray[z])

Announcements


Top Tags