0

I am trying to print the following XML as


PLCO_ID is A-006884-2

Trt_numc is 103

Trt_familyc is 1

Trt_days is 2513

Neoadjuvant is 0


PLCO_ID is A-008288-4

Trt_numc is 104

Trt_familyc is 1

Trt_days is 331

Neoadjuvant is 0


Etc. etc.

However, I have been getting an error. I believe my loop is correct as I need to use an implicit cursor for this particular problem. I think I may have to use rpad() in my print to have it print out correctly but I'm not sure. The code is attached below. Thanks in advance for the help!

The XML code is this

enter image description here

enter image description here

1 Answers1

0
begin
    for x in (select j.onepatient.extract('//PLCO_ID/text()').getstringval() as PLCO_ID, 
    j.onepatient.extract('//trt_numc/text()').getstringval()as Trt_numc, j.onepatient.extract('//trt_familyc/text()').getstringval() as Trt_familyc, 
    j.onepatient.extract('//trt_days/text()').getstringval() as Trt_days,j.onepatient.extract('//neoadjuvannt/text()').getstringval() as Neoadjuvant 
    from treatment_xml j)
    loop
        dbms_output.put_line('PLCO_ID        is: '||x.PLCO_ID ||chr(10) ||'Trt_numc       is: '||x.Trt_numc ||chr(10) ||
        'Trt_familyc    is: ' || x.Trt_familyc || chr(10) || 'Trt_days       is: ' || x.Trt_days|| chr(10)||
        'Neoadjuvant    is: ' || x.Neoadjuvant || chr(10));
    end  loop;
end;/
  • the way you formatted your answer is how we were trying to get you to format your question... – thatjeffsmith Apr 18 '22 at 17:02
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – w. Patrick Gale Apr 18 '22 at 19:28