I want to select rows from a table called Users where the column Logon is equal to "foo" – However, I also want to return "Foo" or "FOO".
I could do something like:
SELECT Id, Name FROM Users WHERE UPPER(Logon) = 'FOO';
And then convert my parameter to uppercase. However, in our code we have literally hundreds of spots where we’d have to update this.
Is there a way to make the table schema itself case-insensitive so these queries will just work without modification? Thanks!
UPDATE
I’d rather not change case-sensitivity in the entire database or at the session level. Changing SQL queries is hard since we use the .NET Entity Framework and have LINQ queries against this table all over the place. It doesn’t appear the EF supports automatically converting case unless you want to change every LINQ query as well.
Answering my own question because I didn’t feel that either of the proposed answers really addressed the issue.
Oracle does not support the concept of a case-insensitive column type, and case sensitivity can only be controlled at the database or session level. There’s a few ways around this, such as making the column virtual or reading through a view, but each of them would also require you to cast the right operand as well (such as
WHERE X = UPPER(:p1).I ended up just updating my database (which was a list of usernames from Active Directory) to have the correct cases, so I no longer have to compare case insensitive.