Seiden Group
Modern Development & Open Source for IBM i
  • Link to LinkedIn
  • Link to Mail
  • Home
  • Seiden PHP+
    • Seiden PHP+
    • Install & Learn
    • SmartSupport
    • PHP Migrations & Upgrades
    • Success Stories
    • Free PHP Assessment
    • Documentation
    • What’s New (Changelog)
  • IBM i Services
    • Development
    • Training & Mentoring
    • Open Source Setup & Upgrades
    • SSL/TLS Install & Learn
    • Performance
  • Support
    • Open Source & PHP
    • VS Code for i
    • Developer Support
    • Support Success Stories
  • VS Code for i
    • Support
    • Training
    • Code for i Resource Guide
    • Getting Started Videos
    • Code for IBM i Fridays
  • Free Stuff
    • IBM i Strategy & Tips
    • PHP Upgrade Assessment
    • CNX Valence Assessment
    • VS Code for IBM i Resources
    • Code for IBM i Fridays
    • QCachegrind Download
    • PHP Toolkit for IBM i Resources
    • Qshell on i Library
  • Blog
  • About
    • About Our Team
    • About Alan Seiden
    • Speakers & Sessions
    • In the News
  • Contact
  • 201.447.2437
  • Search
  • Menu Menu

Seiden Group Blog

Case-Insensitive Queries using ODBC on IBM i

September 30, 2022/0 Comments/in ODBC, Open Source /by Alan Seiden

ODBC with Db2 for IBM iWhen querying for character data using SQL, case matters. “A” is not equal to “a”. Even so, you might want to find all matches, whether uppercase, lowercase, or mixed case.

If you use ODBC, the IBM i driver offers keywords to provide case-insensitivity.

We will demonstrate using the sample table QIWS.QCUSTCDT, which contains a column called CITY that includes a mixed case value, ‘Dallas’.

I can test using the standard isql command, specifying my default ODBC Data Source Name (DSN), which is *LOCAL:

1
isql -v -k DSN=*LOCAL

From the isql command line I search for uppercase DALLAS. I get back no matching rows:

1
2
3
4
5
6
SQL> select * from QIWS.QCUSTCDT where city = 'DALLAS'
+---------+---------+-----+--------------+-------+------+--------+-------+-------+---------+---------+
| CUSNUM | LSTNAM | INIT| STREET | CITY | STATE| ZIPCOD | CDTLMT| CHGCOD| BALDUE | CDTDUE |
+---------+---------+-----+--------------+-------+------+--------+-------+-------+---------+---------+
+---------+---------+-----+--------------+-------+------+--------+-------+-------+---------+---------+
SQLRowCount returns -1

To create a case-insensitive connection, I then edited /QOpenSys/etc/odbc.ini and added an additional DSN called NOCASE:

1
2
3
4
5
6
7
8
9
10
[NOCASE]
Description = Default IBM i local database
Driver = IBM i Access ODBC Driver
System = localhost
UserID = *CURRENT
Pooling = No
; these are the added keywords for case-insensitivity
SortWeight = 0
SortSequence = 2
LanguageID = ENU

By adding the combination of keywords SortWeight = 0, SortSequence = 2, and LanguageID = ENU (use your own language), this DSN becomes case-insensitive.

Then I test with my new NOCASE DSN:

1
isql -v -k DSN=NOCASE

Testing whether we can search for uppercase DALLAS against mixed case Dallas:

1
2
3
4
5
6
SQL> select * from QIWS.QCUSTCDT where city = 'DALLAS'
+---------+---------+-----+--------------+-------+------+--------+-------+-------+---------+---------+
| CUSNUM | LSTNAM | INIT| STREET | CITY | STATE| ZIPCOD | CDTLMT| CHGCOD| BALDUE | CDTDUE |
+---------+---------+-----+--------------+-------+------+--------+-------+-------+---------+---------+
| 938472 | Henning | G K | 4859 Elm Ave | Dallas| TX | 75217 | 5000 | 3 | 37.00 | 0 |
| 593029 | Williams| E D | 485 SE 2 Ave | Dallas| TX | 75218 | 200 | 1 | 25.00 | 0 |

It worked!

Note: If, instead of editing your DSN, you provide connection string keywords to your application directly, the keywords are SORTWEIGHT, SORTSEQUENCE, and LANGUAGEID.

For more information on connection strings and DSNs, see ODBC Connection Strings for IBM i Db2.

Tags: IBM i, odbc, open source
Share this entry
  • Share on Facebook
  • Share on X
  • Share on Pinterest
  • Share on LinkedIn
  • Share on Tumblr
  • Share on Reddit
  • Share by Mail
https://www.seidengroup.com/wp-content/uploads/2017/03/SeidenLogo-180.png 0 0 Alan Seiden https://www.seidengroup.com/wp-content/uploads/2017/03/SeidenLogo-180.png Alan Seiden2022-09-30 11:55:032023-01-31 13:19:51Case-Insensitive Queries using ODBC on IBM i
Alan Seiden

About Alan Seiden

Alan works to preserve your investment in IBM enterprise systems by designing and implementing modernization strategies that leverage your existing business logic.

With a passion ...Read More

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

SUBSCRIBE
Open Thinking
Monthly IBM i Strategy & Tips
  • This field is for validation purposes and should be left unchanged.

IBM i Development

  • RPG, COBOL, SQL, Node,
    PHP, Python, Valance, etc.
  • Modernization. Integration.
  • Web and API Solutions
  • Legacy Maintenance
    ...
LET'S GET IT DONE!

Recent Posts

  • Do You Need IBM i Observability?
  • PHP 8.6 is Coming Soon to IBM i
  • Safer npm installation is on the way for Node.js (and all JavaScript)
  • Access Modern Security for IBM i and Connected Web Environments
  • IBM i: A Natural Platform for Agentic AI
  • PHP on IBM i in 2026: The Modernization Engine
  • Your “AS/400” Is a Modern IBM i Platform
  • MCP + AI for IBM i Teams (with a MongoDB example)
  • GnuPG PHP Extension for IBM i: Now Included with Seiden Support
  • Getting Started with Code for IBM i: A Lunch & Learn Video

SEIDEN GROUP: Modern Development & Open Source for IBM i

Home   |   Seiden PHP+   |   IBM i Services  |   Support   |   VS Code for i   |   Free Stuff   |   Blog  |   Privacy Policy  |   Contact         201.447.2437

© 2026 Seiden Group, LLC
  • Link to LinkedIn
  • Link to Mail
Link to: Learn about Merlin for IBM i Link to: Learn about Merlin for IBM i Learn about Merlin for IBM i Link to: Tips for Fast, Reliable Open Source on IBM i Link to: Tips for Fast, Reliable Open Source on IBM i Tips for Fast, Reliable Open Source on IBM i
Scroll to top Scroll to top Scroll to top