Monday, March 26, 2012

ORA-00932: inconsistent datatypes: expected - got CLOB

One thing I must share is, I have explained what I was facing and that is explained below. If  you are facing same problem then it is pleasure for me, my post is helpful for you. But if this is not the case then please visit following links may be you can find some thing for you.
Can't export my database using exp with XMLTYPE member column


And please let me know what kind of problem you are facing by leaving comment so that I can blog about that too.

Today when I was trying to execute following query it errors out "ORA-00932: inconsistent datatypes: expected - got CLOB". Though it works fine for "distinct cust.*", "distinct hp.*", "distinct hps.*" and "distinct hpsu.*","distinct cust.*" but when I try to SELECT distinct rows from raa ("distinct raa.*") it errors out.
I have googled this problem but no cure because everyone suggested to check database and change the data types. Though in other cases it could be only achieved by making changes in database but in my case I just remove "DISTINCT" from query and it works fine. :)

    FROM hz_cust_accounts cust,
                 hz_parties hp,
                 hz_party_sites hps,
                 hz_party_site_uses hpsu,
                 ra_addresses_all raa
 WHERE cust.party_id = hp.party_id
       AND hp.party_id = hps.party_id
       AND raa.org_id =:p_org_id
       AND hpsu.SITE_USE_TYPE = 'BILL_TO'

ORA-00932: inconsistent datatypes: expected - got CLOB

In addition when I try to drill the error what I found that we cannot ORDER BY or Distinct a CLOB. I first Describe the table and checked which field is having CLOB data type.

Now I know that "ADDRESS_TEXT" is the field. I try to run the following queries

select distinct raa.ADDRESS_TEXT
  from ra_addresses_all raa

select raa.ADDRESS_TEXT
  from ra_addresses_all raa
order by raa.ADDRESS_TEXT

each query returned the same error.

Now I try the following query and it works fine.

select distinct dbms_lob.substr(raa.ADDRESS_TEXT)
  from ra_addresses_all raa
order by dbms_lob.substr(raa.ADDRESS_TEXT)

You can too use this function to avoid the error dbms_lob.substr()

Your feedback/comment is quite important for improving this blog so feel free to leave your comments & suggestions



  1. Thank you! This helped me with trying to figure out how I was getting this error and what to do to get around it. Well, now that I have this, I'm another step along the journey!

    Thanks for this!

    1. You are always welcome.
      Looking forward for your suggestions.

  2. I have the same problem but with OWB 11g while trying to import data from a SQL Server to an Oracle database. The mapping which makes migrating data possible returns this error fact that makes it impossible to fill the oracle table with data. Do you have any idea about what I should do?

    1. Have you tried this dbms_lob.substr()?

  3. I got into this scenario when concatenating multiple records in one col to a single cell value. I got struck and searching for solution. I applied your solution and it worked!!!.
    Thank you very much!!!

  4. But the dbms_log.substr(<>,[startindex],[numberofchar]) doesn't work in this case. Have anyone tried this ?

    Thanks Ritesh

    1. Dear Ritesh,
      I have tried following query and it worked fine,

      select dbms_lob.substr(ADDRESS_TEXT) a,
      dbms_lob.substr(ADDRESS_TEXT,1,10) b


  5. I got this issue while using comment field in union, used dbms_lob.substr and this helped. Thank you..Amit

  6. select distinct "Organization ID",
    en.entity_id "Contact ID",
    en.entity_cd "Note Entity Code",
    ed.entity_name "Note Entity",
    en.entity_id "Note Entity_id",
    en.note_dt "Note Date",
    en.create_dt "Create Date",
    en.update_dt "Update Date",
    FN_LOCALIZE_BI(nt.desc_id, 'EN', 'default') "Type",
    en.subject "Subject",
    replace(replace(dbms_lob.substr(en.description, 4000, 1),
    '\n') "Content"
    from entity_notes en
    left join note_type nt
    on nt.type_cd = en.note_type
    left join entity_definition ed
    on en.entity_cd = ed.entity_cd
    inner join contact_owner co
    on co.contact_id = en.entity_id
    inner join organization o
    on = co.organization_id
    where (en.sync_src_cd = 'MANUAL' or en.sync_src_cd is null)

    this is the original query

    with this query client is getting only 4000 characters for the description column.

    They need almost to 32000 characters for the description column with the same query and logic
    Any way this can be achieved?

  7. Thank you so helped !!! :)

  8. i use TO_CHAR instead of SUBSTR

  9. faced same issue after upgrade to 11g from 10g.
    Error Message: ORA-00932: inconsistent datatypes: expected - got CLOB

    modified column size from varcha2(255) to varchar2(300) and it worked.

  10. Regards
    Sridevi Koduru (Senior Oracle Apps Trainer
    LinkedIn profile -
    Please Contact for One to One Online Training on Oracle Apps Technical, Financials, SCM, SQL, PL/SQL, D2K at | +91 - 9581017828.

  11. Super It dbms_lob.substr worked for me