I have an XML field in a table in my database with data similar to :
and a query like:
With the .query and cast I can get what I need, but...
With the .value function I get the error: XQuery [Applications.xfdf.value()]: 'value()' requires a singleton (or empty sequence), found operand of type 'xdt:untypedAtomic *'
How Do I make my .value xquery a singleton?
The attributes in your xml and the script don't match, but here is the script which will work:
The idea is that because you have xml shape such that you only need it to return a single value for each .value() applied, you simply need to point it to the fragment which is uniquely identified. In this case, though the field nodes make up a collection, they all have unique attribute named name. Therefore, if you pass something like
(//field[@name="desired_name"]/value) as the first parameter to the value() method. The second parameter is the name of the data type.
Hope this helps,Oleg