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');


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
slightwv (䄆 Netminder) Commented:
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
slightwv (䄆 Netminder) Commented:
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.
slightwv (䄆 Netminder) Commented:
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.