powered by simpleCommunicator - 2.0.60     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / IBM DB2, WebSphere, IMS, U2 [игнор отключен] [закрыт для гостей] / В GROUP BY поле больше 255 знаков.
5 сообщений из 5, страница 1 из 1
В GROUP BY поле больше 255 знаков.
    #33540633
nevsky
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
есть некий запрос:

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
select
...
dda.attribute_value as direct_allocation ,
dda1.attribute_value as residue_allocation
from
db.run rn
...
left join db.dmg_db_attr  dda
on ddk.db_id = dda.db_id and dda.attribute_name='MailSort.Direct'
left join db.dmg_db_attr  dda1
on ddk.db_id = dda1.db_id and dda1.attribute_name='MailSort.Residue'
WHERE
rn.report_index =  8 
....
GROUP BY GROUPING SETS
((..., ..., dda.attribute_value, dda1.attribute_value),
(..., ..., ...))
ORDER BY
..., ..., ..., ....

весь запрос не привожу, потому что он достаточно большой, но смысл проблемы будет понятен

поле attribute_value в таблице db.dmg_db_attr имеет размер 1024, поэтому DB2 ругается на этом месте.

SQL0134N Improper use of a string column, host variable, constant, or function "ATTRIBUTE_VALUE". SQLSTATE=42907

в описании ошибок можно узнать, что он не поддерживает в GROUP BY поля, размер которых более 255.

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
SQL0134N	Improper use of a string column, host variable, constant, or function "<name>".

Explanation: The use of the string "<name>" is not permitted.

An expression resulting in a string data type with a maximum length greater than  255  bytes is not permitted in:

    * A SELECT DISTINCT statement
    * A GROUP BY clause
    * An ORDER BY clause
    * A column function with DISTINCT
    * A SELECT or VALUES statement of a set operator other than UNION ALL. 

An expression resulting in a LONG VARCHAR or LONG VARGRAPHIC data type is not permitted in:

    * A predicate other than EXISTS or NULL
    * A column function
    * The SELECT clause of a subquery of a predicate other than EXISTS or NULL
    * The SELECT clause of a subselect in an INSERT statement
    * The value expression of a SET clause in an UPDATE statement unless the expression is a LONG VARCHAR or LONG VARGRAPHIC host variable
    * A SELECT statement of a set operator (except UNION ALL)
    * VARGRAPHIC scalar function. 

Federated system users: in a pass-through session, a data source-specific restriction can cause this error. See the SQL Reference documentation for the failing data sources.

The statement cannot be processed.

User Response: The requested operation on the string is not supported.
Note:	If it is unclear as to how the  255  byte limit is being exceeded, consider that codepage conversion operations may be required to evaluate the string expression. Depending on the source and target codepages, the target may have a greater length attribute than the source. For more information, refer to the SQL Reference for discussions on string restrictions and string conversions.
sqlcode: - 134 

sqlstate:  42907  
может кто подскажет как обойти это ограничение, или что-то еще.

пробовал также substr(ATTRIBUTE_VALUE, 255) - не помогает, продолжает крыть тем же матом
...
Рейтинг: 0 / 0
В GROUP BY поле больше 255 знаков.
    #33542371
golsa
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Код: plaintext
substr(ATTRIBUTE_VALUE,  255 )
-это с 255 и до конца, надо

substr(ATTRIBUTE_VALUE, 1, 255)
...
Рейтинг: 0 / 0
В GROUP BY поле больше 255 знаков.
    #33543251
nevsky
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Так тоже пробовал, ничего не дает
...
Рейтинг: 0 / 0
В GROUP BY поле больше 255 знаков.
    #33545090
golsa
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
попробуй
CHAR(ATTRIBUTE_VALUE, 255)
...
Рейтинг: 0 / 0
В GROUP BY поле больше 255 знаков.
    #33546507
Victor Metelitsa
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
nevskyТак тоже пробовал, ничего не дает
Почему, собственно?
Не забудьте, что вам нужно менять ATTRIBUTE_VALUE на substr(ATTRIBUTE_VALUE, 1, 255) не только в GROUP BY, но и в колоночных выражениях после SELECT.
...
Рейтинг: 0 / 0
5 сообщений из 5, страница 1 из 1
Форумы / IBM DB2, WebSphere, IMS, U2 [игнор отключен] [закрыт для гостей] / В GROUP BY поле больше 255 знаков.
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]