4

I'm new to DB2 and am connecting to a DB2 for i (V7R1) database using unixODBC and the IBM i Access ODBC driver for Linux.

When I query the database, the results only include the first letter of the column names. For example, a typical query run with the isql utility will give me something that looks like this:

SQL> SELECT column1, column2 FROM schema.table WHERE column1 = 12345
+--------+---------------------------------+
| C      | C                               |
+--------+---------------------------------+
| 12345  | Lorem ipsum dolar sit           |
+--------+---------------------------------+
SQLRowCount returns -1
1 rows fetched

This is a problem for me because when I try to query the database in applications (e.g. using the pyodbc library for Python), I can't access the results by column name; both columns are named "C" in the result set.

My questions are:

  1. Why is this happening?
  2. Is it possible to change this behavior? (How?)

EDIT:

This happens even if I try to give the columns aliases:

SQL> SELECT column1 as foo, column2 as bar FROM schema.table WHERE column1 = 12345
+--------+---------------------------------+
| F      | B                               |
+--------+---------------------------------+
| 12345  | Lorem ipsum dolar sit           |
+--------+---------------------------------+
SQLRowCount returns -1
1 rows fetched
  • Odd. What happens if you try and alias them using column1 as blahblah? – Philᵀᴹ Apr 22 '16 at 12:16
  • It gives me the first letter of the alias, strangely enough. Though that was a good thought -- I'll add it to the question details. – Liv Carman Apr 22 '16 at 12:19
  • Is it this? github.com/jiangwen365/pypyodbc/issues/25 – Philᵀᴹ Apr 22 '16 at 12:21
  • Thanks! pyodbc does get the column names correctly if I use it with Python 2.7. So that solves my immediate problem. I'm curious about what's going on with the isql tool, though -- that's just a command-line utility. – Liv Carman Apr 22 '16 at 12:27
  • Which version of i5/OS are you on? that may be affecting things, as DB2 for i is actually integrated with the OS and only upgraded as the OS is upgraded. – Chris Aldrich Apr 22 '16 at 12:47
4

The defect with only the first character of the column name being returned is described in IBM APAR SE63700:
http://www-912.ibm.com/n_dir/nas4apar.NSF/b6c9b771e38b5ea2862564c00079d110/0f43bb0435716de586257f340041ed7a?OpenDocument

The fix should be integrated into the new version of the IBM Access Client Solutions Application Package for Linux, due mid-July 2016.

4

I believe this is a bug with the specific version of IBM's driver I was using. I was using the ODBC driver from IBM i Access Client Solutions Linux AP v07.03.00.

I replaced that driver with the ODBC driver from IBM i Access for Linux v7.1.0-1.0 and now everything works as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.