We help IT Professionals succeed at work.
Get Started

PLSQL Table of XMLType

Wasim Akram Shaik
on
841 Views
Last Modified: 2012-04-19
Pls help me to spot the error in the below block

CREATE OR REPLACE TYPE xmlobj AS OBJECT (
   col   XMLTYPE
);
/

CREATE OR REPLACE TYPE xmltab AS TABLE OF xmlobj;
/

CREATE TABLE XMLTABLE1
(
  COL1  XMLTYPE
)



DECLARE
   -- l_obj   xmltab;
   i       NUMBER;

   CURSOR c1
   IS
      SELECT XMLELEMENT (object_id, object_id) AS object1
        FROM user_objects
       WHERE ROWNUM <= 10;

   l_obj   xmltab := xmltab ();
BEGIN
   i := 1;

   FOR l1 IN c1
   LOOP
      l_obj.EXTEND;
      l_obj (i) := xmlobj (l1.object1);
      i := i + 1;
   END LOOP;

   FORALL i IN 1 .. l_obj.COUNT
      INSERT INTO xmltable1
           VALUES l_obj (i);
END;

Error on executing this block is

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

 26  /
      INSERT INTO xmltable1
      *
ERROR at line 23:
ORA-06550: line 23, column 7:
PL/SQL: ORA-00932: inconsistent datatypes: expected - got -
ORA-06550: line 23, column 7:
PL/SQL: SQL Statement ignored


SQL>
Comment
Watch Question
Database Developer & Administrator
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2012
Commented:
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE