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:
- Why is this happening?
- 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