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

We are happy to announce the new Windchill Customization board! Learn more.

Use of LOWER Operator in wt.query.SearchCondition

BenPerry
13-Aquamarine

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>

1 ACCEPTED SOLUTION

Accepted Solutions
BenPerry
13-Aquamarine
(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
13-Aquamarine
(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])

Top Tags