Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ORA-00932 with CLOB in JOIN

BerndLJul 18 2017 — edited Jul 19 2017

Problem is as follows: I need a concatenated list of names somewhere in my query. This is easy enough to accomplish with LISTAGG, but the result may become longer than 4000 characters, so I decided to use XMLAGG. Query goes like this:

SELECT

  id_flurstueck,

  REGEXP_REPLACE(RTRIM(EXTRACT(XMLAGG(XMLELEMENT(e, bezeichner || '; ') ORDER BY bezeichner), '/E/text()').getclobval(), '; '),

                 '([^;]*)(; \1)+($|;)',

                 '\1\3') AS eigentuemer

FROM

  mv_alkis_eigentuemer

GROUP BY

  id_flurstueck ;

mv_alkis_eigentuemer is a materialized view and the query gives me the expected answer. Slow - but working.

But I need those names in a longer query, and so I join on that SELECT.

SELECT

  ae.eigentuemer,

  manyOtherAttributes

FROM

  myTable t LEFT JOIN (

                        SELECT

                          id_flurstueck,

                          REGEXP_REPLACE(RTRIM(EXTRACT(XMLAGG(XMLELEMENT(e, bezeichner || '; ') ORDER BY bezeichner), '/E/text()').getclobval(), '; '),

                         '([^;]*)(; \1)+($|;)',

                          '\1\3') AS eigentuemer

                        FROM

                          mv_alkis_eigentuemer

                        GROUP BY

                          id_flurstueck

                       ) ae

            ON         t.id_flurstueck = ae.id_flurstueck ;

Unfortunately this results in

ORA-00932: inconsistent datatypes: - expected, CLOB received

Same result if I use the query inline as a correlated subquery.

Any ideas, how to overcome this?

Database is Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production.

Thanks in advance, Bernd

This post has been answered by odie_63 on Jul 18 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 16 2017
Added on Jul 18 2017
11 comments
1,777 views