Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

xmltable: defining columns datatype from table

917785Nov 8 2012 — edited Nov 20 2012
Hi everyone

I'm using ORACLE 11g and looking to shred XML into a test table called employees. I was hoping I'd be able to get the datatypes from the existing employees table instead of specifying them in the columns clause. Is this possible?

Here is an example of what I'm trying to do. But, I get an error: PL/SQL: ORA-00907: missing right parenthesis on the line with starting with columns.
    insert into EMPLOYEES
     select *
       from xmltable(
       '/employees/employee'
        passing EMP_XML

        columns FIRST_NAME EMPLOYEES.FIRST_NAME%TYPE path 'first_name',
                LAST_NAME  EMPLOYEES.LAST_NAME%TYPE  path 'last_name',
                GENDER     EMPLOYEES.GENDER%TYPE     path 'gender',
                AGE        EMPLOYEES.AGE%TYPE        path 'age'
        );
Error Details
        columns FIRST_NAME EMPLOYEES.FIRST_NAME%TYPE path 'first_name',
                            *          

ERROR at line 16:
ORA-06550: line 16, column 42:
PL/SQL: ORA-00907: missing right parenthesis
ORA-06550: line 11, column 5:
PL/SQL: SQL Statement ignored
Thanks.
This post has been answered by odie_63 on Nov 15 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 18 2012
Added on Nov 8 2012
7 comments
3,934 views