DB2 - Problem description
Problem IT19579 | Status: Closed |
SQL119N WHEN REFERENCING HOST VARIABLE WITH GROUP BY IN STATIC SQL | |
product: | |
DB2 FOR LUW / DB2FORLUW / B10 - DB2 | |
Problem description: | |
A static SQL block that contains a combination of the same host variable being referenced multiple times and a GROUP BY clause may cause a SQL0119N error: SQL0119N An expression starting with "T" specified in a SELECT clause, HAVING clause, or ORDER BY clause is not specified in the GROUP BY clause or it is in a SELECT clause, HAVING clause, or ORDER BY clause with a column function and no GROUP BY clause is specified. LINE NUMBER=12. SQLSTATE=42803 Example: EXEC SQL INCLUDE SQLCA; EXEC SQL BEGIN DECLARE SECTION; /*insert host variables here*/ char hv[9] = 'YYYYMMDD'; char val[9]; EXEC SQL END DECLARE SECTION; ... EXEC SQL CREATE TABLE T1 (T TIMESTAMP); ... EXEC SQL SELECT TO_CHAR(T, :hv) INTO :myval FROM T1 GROUP BY TO_CHAR(T, :hv); | |
Problem Summary: | |
**************************************************************** * USERS AFFECTED: * * ALL * **************************************************************** * PROBLEM DESCRIPTION: * * See Error Description * **************************************************************** * RECOMMENDATION: * * See Local Fix * **************************************************************** | |
Local Fix: | |
Rewrite the SQL SELECT statement with a subselect and add an alias to the column: EXEC SQL SELECT C1 INTO :myval FROM (SELECT TO_CHAR(T, :hv) AS C1 FROM T1) GROUP BY C1; | |
Solution | |
Workaround | |
not known / see Local fix | |
BUG-Tracking | |
forerunner : IT13075 follow-up : | |
Timestamps | |
Date - problem reported : Date - problem closed : Date - last modified : | 07.03.2017 07.03.2017 07.03.2017 |
Problem solved at the following versions (IBM BugInfos) | |
Problem solved according to the fixlist(s) of the following version(s) |