|
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?
(comments are locked)
|
|
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)[1] as the first parameter to the value() method. The second parameter is the name of the data type. Hope this helps, Oleg Oleg, You the man! Worked perfect.
Jan 27 '11 at 07:54 PM
Row Z
Now that I have access to this data, it would make sense to index it, for using as a filters in queries. I was able to create a primary XML index, but correct me if I am wrong, but the primary XML index just indexes the XML structure. Can I create indexes a specific field or set of fields within the XML?
Jan 27 '11 at 08:12 PM
Row Z
@Row Z - yes you can - secondary XML indexes are what you want there. As Oleg's answer was the correct one (as ever), could you please mark the answer as correct by clicking the tick box to the left of his answer? Thanks.
Jan 28 '11 at 03:08 AM
Matt Whitfield ♦♦
(comments are locked)
|

