We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now



Medium Priority
Last Modified: 2013-11-19
I am getting the following error when I try to compile the following PLSQL script
PL/SQL: ORA-00932: inconsistent datatypes: expected NUMBER got -.

Does anyone know why I am getting this error?

CREATE OR REPLACE Procedure xmldoc (setid_in in varchar2, customerid_in in VARCHAR2)

   NAME:       xmldoc
   PURPOSE:    Combine multiple xml documents into one xml document.
   Ver        Date        Author           Description
   ---------  ----------  ---------------  ------------------------------------
   1.0        04-10-2006  TCleveland        1. Created procedure.

v_clob    CLOB;


       xmlelement("MESSAGEGROUP", xmlagg(xmlelement("STATE",cust_keys, xmlcontent,
                                               xmlelement("StateMessage",(select xmlagg(xmlelement("Message", cust_keys,xmlcontent, xmlelement("Attributes",(select xmlagg(xmlelement("Attribute", cust_keys, xmlcontent)) from envdbr3.xmledit
                                      where formname='InsuranceFraud_Attribute'
                                                and extractvalue(cust_keys,'/xmlkeys/kv1')=extractvalue(c.cust_keys,'/xmlkeys/kv1')
                                                and extractvalue(cust_keys,'/xmlkeys/kv2')=extractvalue(c.cust_keys,'/xmlkeys/kv2')
                                                and extractvalue(cust_keys,'/xmlkeys/kv3')=extractvalue(c.cust_keys,'/xmlkeys/kv3')
                                                group by extractvalue(cust_keys,'//kv1'),extractvalue(cust_keys,'//kv2'),extractvalue(cust_keys,'//kv3')
                                 )      )) from envdbr3.xmledit c
                                                                      where formname='InsuranceFraud_MessageGroup'
                                                                                and extractvalue(cust_keys,'/xmlkeys/kv1')=extractvalue(x.cust_keys,'/xmlkeys/kv1')
                                                                                and extractvalue(cust_keys,'/xmlkeys/kv2')=extractvalue(x.cust_keys,'/xmlkeys/kv2')
                                                                                group by extractvalue(cust_keys,'//kv1'),extractvalue(cust_keys,'//kv2')
               ) as xmldoc into v_clob
 from envdbr3.xmledit x
where formname='InsuranceFraud_StateGroup'
and extractvalue(cust_keys,'/xmlkeys/kv1/@name')='SET_ID'
and extractvalue(cust_keys,'/xmlkeys/kv1')='0001'
and extractvalue(cust_keys,'/xmlkeys/kv5')= 'AL'
group by extractvalue(cust_keys,'//kv1'),extractvalue(cust_keys,'//kv2');


Watch Question

You are getting error due to One of the following:

An attempt was made to perform an operation on incompatible datatypes. For example, adding a character field to a date field (dates may only be added to numeric fields) or concatenating a character field with a long field.
An attempt was made to perform an operation on a database object (such as a table or view) that is not intended for normal use. For example, system tables cannot be modified by a user. Note that on rare occasions this error occurs because a misspelled object name matched a restricted object's name.
An attempt was made to use an undocumented view.
So If the cause is different datatypes, then use consistent datatypes. For example, convert the character field to a numeric field with the TO_NUMBER function before adding it to the date field. Functions may not be used with long fields.
an object not intended for normal use, then do not access the restricted object.
Chetan Sachdeva

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Most Valuable Expert 2012
Distinguished Expert 2019

99% of the time when you see: "inconsistent datatypes: expected ??? got -" the "-" (dash) involves a LOB.

The output of xmlelement is of XMLTYPE and you are trying to put it into a CLOB.

             ) as xmldoc into v_clob
             ).getclobval() as xmldoc into v_clob
Most Valuable Expert 2012
Distinguished Expert 2019

Forgot to add:
The code you provided seems a bit much just to merge several XML docs into a single doc.  I'd be happy to try to give you some other possible options if you can provide a little more detail about the problem.  If you want me to look into this more, please provide me the full Oracle version you are on.
Most Valuable Expert 2012
Distinguished Expert 2019

I'm afraid I have to disagree with the recommendation.  I don't think that pasting the text from the error code from the online documentation should ever get points.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.