I'm trying to do the following SELECT statement in DB2 stored procedure:
FOR c AS ( SELECT o.id id
,o.col1 col1
,o.title title
,o.locale locale
,lower(desc1.detail1) CONCAT lower(desc1.detail2) CONCAT lower(desc1.detail3) CONCAT lower(desc1.detail4) description
,lower(absc1.detail1) || lower(absc1.detail2) || lower(absc1.detail3) || lower(absc1.detail4) abstract
FROM table_name o
INNER JOIN desc_table ON o.id = desc1.some_id
AND o.desc1 = desc1.id
INNER JOIN table_detail absc1 ON o.id = absc1.owner_id
AND o.abstract = absc1.id
WHERE o.id = xid
) DO
and taking the following error:
[IBM][CLI Driver][DB2/NT64] SQL0789N The data type for parameter or SQL variable "DESCRIPTION" is not supported in the routine, compound SQL statement, or parameter list of a cursor value constructor. LINE NUMBER=... SQLSTATE=429BB
The problem is in lower(desc1.detail1) CONCAT lower(desc1.detail2) CONCAT lower(desc1.detail3) CONCAT lower(desc1.detail4) description
line
Seems that alias description
is not appropriate for concatenated strings.
The same situation is for:
lower(absc1.detail1) || lower(absc1.detail2) || lower(absc1.detail3) || lower(absc1.detail4) abstract
Maybe You have any suggestions?
Thanks.