Generating XML document from table containing Nested table -
05-11-2006
, 09:26 AM
Hi,
I am an XML newbie. I am trying to retrieve data , in the form of XML from a table that has a nested table.
My table structure is as follows :-
CREATE OR REPLACE
TYPE Course AS OBJECT (
course_no NUMBER(4),
title VARCHAR2(35),
credits NUMBER(1))
/
CREATE OR REPLACE
TYPE CourseList AS TABLE OF Course
/
CREATE TABLE DEPARTMENT
(
NAME VARCHAR2(20 BYTE),
DIRECTOR VARCHAR2(20 BYTE),
OFFICE VARCHAR2(20 BYTE),
COURSES COURSELIST
)
NESTED TABLE COURSES STORE AS COURSES_TAB;
SQL> desc department
Name Null? Type
----------------------------------------- -------- ----------------------------
NAME VARCHAR2(20)
DIRECTOR VARCHAR2(20)
OFFICE VARCHAR2(20)
COURSES COURSELIST
I am issuing the following command in Oracle 10g, but I am getting an error .
SELECT XMLForest(department(d.dname,d.director, d.office,
CAST(MULTISET(
select e.course_no, e.title "Course_title"
from table(d.courses) e
where e.deptno = d.deptno) AS "test")) AS "Department")
AS deptxml
FROM department d;
ERROR at line 5:
ORA-00902: invalid datatype
I would really appreciate any help. Thanks in advance.
S |