oracle - got multi-item sequence -


my intention "select data container number equals input data" (kind of search functionality). facing issue when trying retrieve data, problem @ condition:

d:goodsshipments/d:consignment/d:transportequipment/d:id/text() 

here getting multiple data. don't know how iterate in condition.

my query is:

my source xml is:

how can select declaration sealid 5678? how deal condition in case?

you have multiple containers per consignment, , you're filtering based on lrn after extracting raw xml; need use nested xmltable objects. first 1 gets data declaration , extracts consignments sub-xmltype. passed second xmltable extracts container information.

select x1.lrn, x1.username, x2.containernumber dmsimport_decl d cross join xmltable(   xmlnamespaces(default 'http://www.xxxx.invalid/xxxx/xxx/schema/xxx',     'http://www.xxxx.invalid/xxx/schema/common' "c",     'http://www.xxxx.invalid/xxxx/xxx/schema/xxx' "d"),   '/d:declaration'   passing d.object_value   columns     lrn varchar2(35 char)       path 'c:declarationheader/c:localreferencenumber/text()',     username char(25)       path 'c:declarationheader/c:username/text()',     consignment xmltype       path 'd:goodsshipments/d:consignment' ) x1 cross join xmltable(   xmlnamespaces(default 'http://www.xxxx.invalid/xxxx/xxx/schema/xxx',     'http://www.xxxx.invalid/xxx/schema/common' "c",     'http://www.xxxx.invalid/xxxx/xxx/schema/xxx' "d"),   '//d:transportequipment'   passing x1.consignment   columns     containernumber varchar2(35 char)       path 'd:id/text()' ) x2 x1.lrn = 'nldms111111150010950'; 

with (updated) sample xml, produces:

lrn                                 username                  containernumber                    ----------------------------------- ------------------------- ----------------------------------- nldms111111150010950                testsc testsc             abcd                                nldms111111150010950                testsc testsc             bcde                                nldms111111150010950                testsc testsc             cdef                                nldms111111150010950                testsc testsc             defg                                nldms111111150010950                testsc testsc             efgh                                

hopefully want see.

quick sql fiddle demo.

you use more complicated xpath keep within single xmltable, think clearer.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -