当与GROUP BY子句一起使用时,如何解决“ ORA-00932:数据类型不一致:预期-获得CLOB”的问题?

时间:2019-03-25 10:33:17

标签: sql oracle

我正在为业务逻辑创建一个视图,该视图包含来自多个表的约25列。其中一个字段称为“ person_description”,大约有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:数据类型不一致:预期-得到CLOB”的错误。

我对这个问题的理解是,GROUP BY子句不适用于clob字段。我不想使用SUBSTR并截断该字段,因为按原样获取整个内容很重要。

我正在寻找任何解决方法或解决方案。 预先感谢。

2 个答案:

答案 0 :(得分:0)

要坚持“示例”,您可以在分组后添加clob列。我假设employee_id是您的主键。 HTH KR彼得

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;

答案 1 :(得分:-1)

尝试使用to_char:

Private Sub cmdSubmit_Click()

    Dim temp As Variant
    Dim c As Control
    Dim myCount As Long

    '0 based array starting with a single element
    ReDim temp(0 To 0)
    myCount = 0

    'Check each control for a textbox
    For Each c In Me.Frame1.Controls
        If TypeOf c Is MSForms.TextBox Then
            'if there is a value in the texbox then assign it to an array
            If c.Value <> "" Then
                temp(myCount) = c.Value
                myCount = myCount + 1
                'set upperbound of the array +1 when a new value is found
                ReDim Preserve temp(0 To UBound(temp) + 1)
            End If
        End If
    Next c
    myCount = 0

    'Remove the last array element as it must be blank
    ReDim Preserve temp(0 To UBound(temp) - 1)

    'Create a string of each value joined with a comma and space
    Dim myString As String
    myString = Join(temp, ", ")

    ThisWorkbook.Sheets(1).Range("C5").Value = myString

End Sub

仅当Clob <4000个字符时有效