Re: Case insensitive FieldCompareRangePredicate comparison with Oracle 11g

Posts   
 
    
Krish
User
Posts: 91
Joined: 02-Jan-2008
# Posted on: 27-Jul-2012 10:21:39   

Hi, How can I do a case insenstive comparison using the FieldCompareRangePredicate which results in the 'in' clause in the sql query.

For example with other predicates (e.g. FieldLikePredicate) I can use the CaseSensitiveCollation = true option but cant do that with FieldCompareRangePredicate.

I am using LLBLGen Pro 2.6 Final and Adapter and C#. Oracle back end database (11g) with Oracle drivers.

Thank you.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 27-Jul-2012 17:00:14   

How would you write this in SQL for Oracle?

Krish
User
Posts: 91
Joined: 02-Jan-2008
# Posted on: 27-Jul-2012 21:50:25   

Something like the following: (I am at home at present so do not have access to my work development computer)

Basic query:

SELECT column_name(s) FROM table_name WHERE column_name IN (value1,value2,...)

One way: (using the upper function)

SELECT column_name(s) FROM table_name WHERE upper(column_name) IN (value1,value2,...)

Another way:

SELECT column_name(s) FROM table_name WHERE upper(column_name) IN (upper(value1), upper(value2),...)

I am off to watch the Olympic opening ceremony!

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 27-Jul-2012 23:19:31   

This is a way to do that:

var values = new List<string>() { "alfki", "bRpd", "ZPICA" };

var filter = new RelationPredicateBucket();
filter.PredicateExpression.Add(
    OrderFields.CustomerId.SetExpression(
        new DbFunctionCall("UPPER", new object[] {OrderFields.CustomerId})) 
    == values.Select(val => val.ToUpper()).ToList());

Krish wrote:

I am off to watch the Olympic opening ceremony!

simple_smile

David Elizondo | LLBLGen Support Team
Krish
User
Posts: 91
Joined: 02-Jan-2008
# Posted on: 28-Jul-2012 08:10:15   

Thank you very much, looks pretty cool. I will try this out on Monday and post again.

Krish
User
Posts: 91
Joined: 02-Jan-2008
# Posted on: 30-Jul-2012 05:58:00   

Like the London Olympics works like a charm. Thank you very much.