DB2 - Problem description
Problem IT18732 | Status: Closed |
WHEN RUNNING THE DYNAMIC SQL IN A PACKAGE, THE WRONG STATEMENT COULD BE PICKED UP, RESULTING IN WRONG RESULT. | |
product: | |
DB2 FOR LUW / DB2FORLUW / A50 - DB2 | |
Problem description: | |
This problem surfaces when running a jdbc or sqc package with dynamic SQL with 2 or more dynamic SQL statements in the package. And these consequite sql statements are identical in everything but literal values concatenated into sql through a separate variable. The second prepared statement in package can be mapped to the previously prepared statement in the package cache. This leads the newly prepared statement to be executed as the previous statement in the package and thus leading to wrong results. The problem surfaces when we have NULL bytes in a literal for the SQL statements. Here is snip of example code in Java for reference. ----- : String key1 = new String('AAAAA'); String key2 = new String('BBBBB'); byte [] r1 = { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 }; byte [] r2 = { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff }; String range1 = new String( r1 ); String range2 = new String( r2 ); : PreparedStatement pstmt1 = con.prepareStatement("SELECT * FROM T1 WHERE C1 BETWEEN '" + range1 + "' AND '" + range2 + "' AND C2 = '" + key1 + "'"); : PreparedStatement pstmt2 = con.prepareStatement("SELECT * FROM T1 WHERE C1 BETWEEN '" + range1 + "' AND '" + range2 + "' AND C2 = '" + key2 + "'"); : ----- Even if key1 differs to key2, second query returns the same results as same as the first select statement. | |
Problem Summary: | |
**************************************************************** * USERS AFFECTED: * * DB2 UDB Version 10.5 * **************************************************************** * PROBLEM DESCRIPTION: * * See Error Description * **************************************************************** * RECOMMENDATION: * * Upgrade to Version 10.5 FixPack 9. * **************************************************************** | |
Local Fix: | |
No workaround available. | |
Solution | |
Problem was first fixed in DB2 UDB Version 10.5 FixPack 9. | |
Workaround | |
not known / see Local fix | |
Timestamps | |
Date - problem reported : Date - problem closed : Date - last modified : | 10.01.2017 27.09.2017 12.10.2017 |
Problem solved at the following versions (IBM BugInfos) | |
9.0. | |
Problem solved according to the fixlist(s) of the following version(s) |