Skip to Main Content

DevOps, CI/CD and Automation

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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Extracting attributes from repeating elements into an object

User_YYYL7Jan 26 2021

Hello,
here is one of my attempts I've tried to extract the values of the repeating attributes datefrom, dateto and days in the <nperiods> element.
I've tried various other definitions of the nperiods_T object type, but I keep getting the ORA-19031 error.
Could you please tell me how I should construct the object type to be able to do this?
Thank you,
Pavel
CREATE OR REPLACE TYPE nperiod_T AS OBJECT("@datefrom" varchar2(10),"@dateto" varchar2(10),"@days" varchar2(10));
/
CREATE OR REPLACE TYPE nperiods_T AS OBJECT("nperiod" nperiod_T);
/
declare
ivkX XMLType;
nperiodsX XMLType;
suminsX NUMBER(10);
nperiods_tab nperiods_T;

begin
ivkX:=xmltype(
'<ivk>
<nperiods>
<nperiod datefrom="1965-10-03" dateto="1965-10-03" days="1" />
<nperiod datefrom="2005-09-01" dateto="2009-12-31" days="1583" />
<nperiod datefrom="2013-01-01" dateto="2013-12-31" days="8" />
</nperiods>
</ivk>');
nperiodsX:=ivkX.EXTRACT('//ivk/nperiods');
nperiodsX.ToObject(nperiods_tab);

end;
/
ERROR at line 1:
ORA-19031: XML element or attribute nperiod does not match any in type IDB_MIG.NPERIODS_T
ORA-06512: at "SYS.XMLTYPE", line 196
ORA-06512: at line 33

Comments

Post Details

Added on Jan 26 2021
0 comments
223 views