0

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.

4

1 回答 1

1

尝试

JOIN desc_table desc1

问题似乎是您没有定义 desc1。

如果 description 是保留字,请更改名称或将其放在双引号中。

在连接的字符串周围使用 lower 也可以获得更好的性能。

lower( a || b || c )
于 2013-06-21T11:44:59.837 回答