Posted on 2006-04-11
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');


Question by:TClevel
    LVL 4

    Accepted Solution

    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
    LVL 76

    Expert Comment

    by:slightwv (䄆 Netminder)
    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
    LVL 76

    Expert Comment

    by:slightwv (䄆 Netminder)
    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.
    LVL 76

    Expert Comment

    by:slightwv (䄆 Netminder)
    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.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    This article describes some very basic things about SQL Server filegroups.
    Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
    Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now