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