开发者

selecting one value out of an xml column

I have a particularly troublesome xml column to query data from. The schema is fixed by the Quebec Ministry of Revenue so "it is what it is"

The important part of the query looks like this:

with XMLNAMESPACES(default 'http://www.mrq.gouv.qc.ca/T5')
select xmldata.value('(//Groupe02/*/Montants/B_PrestREER_FERR_RPDB)[1]', 'decimal(16,2)');

The wildcard between Groupe02 and Montants could be any one of A D R or T. (that's right one letter element names)

Trouble is I need to query to only select A, D or R nodes but not T nodes. as a first guess I tried:

with XMLNAMESPACES(default 'http://www.mrq.gouv.qc.ca/T5')
select @x.value('(//Groupe02/A|D|R/Montants/B_PrestREER_FERR_RPDB)[1]', 'decimal(16,2)');

but that failed with the error "The XQuery syntax 'union' is not supported"

What other possible ways are there to开发者_Go百科 make such a query.


I think using [name()!='T'] might work. E.g.

select @x.value("(//Groupe02/*[name()!='T']/Montants/B_PrestREER_FERR_RPDB)[1]", 'decimal(16,2)');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜