0

i have a table A

id -------- name -------------------C (xml data)

1 -----------a---------------------<note> <to>AKI</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>

2------------ b--------------------<note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>

3------------ c--------------------<note> <to>Joe</to> <from>MARY</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>"

now i want to fetch value of <to> and <from> tags and enter them to other temporary table

I am working on oracle 11g

i tried using

insert into <your_temp_table>
select a.id, a.name, 
   extract(a.c, '/note/to').getStringVal() as to, 
   extract(a.c, '/note/from')getStringVal() as from 
 from A a;

but im getting error

ORA-00932: inconsistent datatypes: expected - got -

Any Suggestions ???

2 Answers 2

1
insert into <your_temp_table>
select a.id, a.name, 
       extract(a.c, '/note/to').getStringVal() as to_value, 
       extract(a.c, '/note/from').getStringVal() as from_value 
  from A a;
Sign up to request clarification or add additional context in comments.

3 Comments

Ussing above querry im getting ORA-00932: inconsistent datatypes: expected - got - Can you suggest anything ?
getStringVal() is for string values. If you have other type stored inside you need to use corresponding function. Please read reference: docs.oracle.com/cd/E11882_01/appdev.112/e40758/…
I've just noticed that there was a typo - missing dot for from column. Btw from is reserved keyword, so it might be better to use another alias.
1

THE PROBLEM The most common cause of this Oracle error occurs when you attempt to execute an operation of two different data types that are incompatible. Remediating these mismatched data types should be the first step taken. In addition, it may have occurred because the user tried to perform an operation on a database object that is not intended for normal use. Otherwise, an attempt may have been made to use an undocumented view.

THE SOLUTION Correct the error by changing the data types to ones that are compatible. You can use a function such as TO_NUMBER or TO_CHAR to correct the compatibility error. (You can find the full list of Oracle functions here.). To avoid getting this error in the future, make sure that data types are compatible against one another.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.