Problem Note 67839: A DB2 VARCHAR data type is incorrectly created in a DB2 table when a column has the TRANSCODE=NO attribute
A DB2 VARCHAR(nn) column is incorrectly created when all the following conditions are true:
- The SAS maintenance release is earlier than SAS® 9.4M7 (TS1M7).
- The DB2 server version is DB2 version 11 or later.
- The SAS column attribute TRANSCODE=NO is assigned.
- You create a DB2 table.
You might also see this issue when the DB2 client and server versions are different. For example, you are using a DB2 version 10 client and a DB2 version 11 server.
For DB2 version 10, you would expect TRANSCODE=NO to result in a DB2 column that is created as "VARCHAR(nn) FOR BIT DATA."
For DB2 version 11, you would expect TRANSCODE=NO to result in a DB2 column that is created as "VARBINARY(nn)."
The following syntax can demonstrate the issue:
LIBNAME db2lib DB=database USER=user-id PW=password ;
OPTIONS SASTRACE=',,,D' SASTRACELOC=SASLOG NOSTSUFFIX ;
DATA db2lib.db2table ;
ATTRIB my-key LENGTH=$32 TRANSCODE=NO ;
my-key='0000C21DE8BC5EEB6EC42B0000000A21'X ;
FORMAT my-key $HEX32. ;
RUN ;
The SASTRACE output shows that the CREATE TABLE clause is generated as one of the following, and the last one is incorrect:
- CREATE TABLE db2table (my-key VARCHAR(32) FOR BIT DATA)
- CREATE TABLE db2table (my-key VARBINARY(32))
- CREATE TABLE db2table (my-key VARCHAR(32))
The only workaround is to use the DBTYPE= data set option, as shown here:
LIBNAME db2lib DB=database USER=user-id PW=password ;
OPTIONS SASTRACE=',,,D' SASTRACELOC=SASLOG NOSTSUFFIX ;
DATA db2lib.db2table(DBTYPE=(my-key= 'VARCHAR(32) FOR BIT DATA'));
ATTRIB my-key LENGTH=$32 TRANSCODE=NO ;
my-key='0000C21DE8BC5EEB6EC42B0000000A21'X ;
FORMAT my-key $HEX32. ;
RUN ;
Click the Hot Fix tab in this note to access the hot fix for this issue.
Operating System and Release Information
SAS System | SAS/ACCESS Interface to DB2 | z/OS 64-bit | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
z/OS | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Microsoft® Windows® for x64 | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Microsoft Windows 8 Enterprise 32-bit | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Microsoft Windows 8 Enterprise x64 | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Microsoft Windows 8 Pro 32-bit | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Microsoft Windows 8 Pro x64 | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Microsoft Windows 8.1 Enterprise 32-bit | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Microsoft Windows 8.1 Enterprise x64 | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Microsoft Windows 8.1 Pro 32-bit | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Microsoft Windows 8.1 Pro x64 | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Microsoft Windows 10 | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Microsoft Windows Server 2008 | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Microsoft Windows Server 2008 R2 | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Microsoft Windows Server 2008 for x64 | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Microsoft Windows Server 2012 Datacenter | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Microsoft Windows Server 2012 R2 Datacenter | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Microsoft Windows Server 2012 R2 Std | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Microsoft Windows Server 2012 Std | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Microsoft Windows Server 2016 | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Microsoft Windows Server 2019 | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Windows 7 Enterprise 32 bit | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Windows 7 Enterprise x64 | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Windows 7 Home Premium 32 bit | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Windows 7 Home Premium x64 | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Windows 7 Professional 32 bit | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Windows 7 Professional x64 | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Windows 7 Ultimate 32 bit | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Windows 7 Ultimate x64 | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
64-bit Enabled AIX | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
64-bit Enabled Solaris | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
HP-UX IPF | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Linux for x64 | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
Solaris for x64 | 9.43 | 9.44 | 9.4 TS1M6 | 9.4 TS1M7 |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
When a SAS® column has TRANSCODE=NO and is used to create a new DB2 table, the DB2 data type that is created should be "VARCHAR(nn) FOR BIT DATA" or "VARBINARY(nn)," not "VARCHAR(nn)."
Type: | Problem Note |
Priority: | high |
Topic: | Data Management ==> Data Sources ==> External Databases ==> DB2
|
Date Modified: | 2021-05-24 09:30:37 |
Date Created: | 2021-04-29 04:53:49 |