oracle 如何修复'ORA-00932:unconsistent datashees:expected - got CLOB'与GROUP BY子句一起使用时的问题?

zzlelutf  于 2023-11-17  发布在  Oracle
关注(0)|答案(3)|浏览(134)

我正在为一个业务逻辑创建一个视图,它有来自多个表的大约25列,其中一个字段,比如'person_conversion',有大约10000个字符,我不想截断。
为了简单起见,我将提供一个小示例(实际查询要大得多)。

create view sample_description as 
select person_description, name, employee_id
from employee_table 
group by person_description, name, employee_id;

字符串
我在person_description字段上得到一个错误'ORA-00932:inconsistent databases:expected - got CLOB'。
我对这个问题的理解是,GROUP BY子句对clob字段不起作用。我不想使用SUBSTR并截断字段,因为按原样获得整个内容很重要。
我正在寻找任何类型的变通办法或解决方案。提前感谢。

n9vozmp4

n9vozmp41#

使用to_char:

create view sample_description as 
select person_description, name, employee_id
from employee_table 
group by TO_CHAR(person_description), name, review_id;

字符串
仅当clob < 4000个字符时有效

i7uaboj4

i7uaboj42#

为了坚持你的“example”,你可以在分组后添加clob列。我假设employee_id是你的主键。HTH KR Peter

create view sample_description as 
select
    (select e2.person_description from employee_table e2 where e2.employee_id = e.employee_id)
    , e.name, e.employee_id
from
    (select ei.name, ei.employee_id
    from employee_table ei
    group by ei.name, ei.employee_id) e;

字符串

wko9yo5t

wko9yo5t3#

CREATE VIEW sample_description AS 
SELECT person_description, name, employee_id
  FROM employee_table 
 WHERE employee_id IN (SELECT employee_id OVER (PARTITION BY employee_id, NAME) 
                         FROM employee_table);

字符串

相关问题