i'm new to xml DB with Oracle and i'm starting to get my bearings around it but there is one thing that is important that i can't figure to do : i need to identify 1. if an element exist 2. if it is empty
unfortunatly the XMLExists() just mix the two answers.
a small part of my query :
SELECT case when XMLEXISTS('/' passing by ref c3.CLASS) then 1 else 0 end E_CLASS,
c3.CLASS
FROM XML_TEST x,
XMLTABLE ('/Data/EMPLOYER'
PASSING x.File_XML
COLUMNS DOSSIER NUMBER(8) PATH 'DOSSIER',
SUMMARY XMLTYPE PATH 'SUMMARY'
) e,
XMLTABLE ('/SUMMARY'
PASSING e.SUMMARY
COLUMNS BEGINDATE DATE PATH 'BEGINDATE',
WORKER XMLTYPE PATH 'WORKER'
) c1,
XMLTABLE ('/WORKER'
PASSING c1.WORKER
COLUMNS NRWORKER NUMBER(7) PATH 'NRWORKER',
RESULT_DETAIL XMLTYPE PATH 'RESULT_DETAIL'
) c2 ,
XMLTABLE ('/RESULT_DETAIL'
PASSING c2.RESULT_DETAIL
COLUMNS CODE CHAR(5) PATH 'CODE',
MINUTES NUMBER(5) PATH 'MINUTES',
CLASS CHAR(1) PATH 'CLASS'
) c3 ;
See Question&Answers more detail:os