Questions tagged [xquery-sql]

the XQuery language as supported by database systems. Include the tag of your system to specify ("sql-server", "oracle", "postgresql", etcetera). Use the "xquery" tag on its own for general questions about XQuery.

XQuery is a query language designed to extract data from arbitrary XML documents. Multiple RDBMSes support XQuery as part of the SQL/XML standard or using proprietary syntax. What follows is a non-exhaustive list.

Microsoft SQL Server

In SQL Server 2005 and onwards, the xml data type methods, in particular .query(), support querying XML and returning the results as relational data. These methods support a subset of XQuery, with special support for some T-SQL specific constructs like variables -- see the XQuery Language Reference for specifics.

Oracle

Oracle includes XML support as Oracle XML DB. It supports XQuery both for querying and updating data, both relational and XML. The XMLQUERY function is used to issue XQuery queries within an SQL statement.

453 questions
0
votes
1 answer

Xquery : querying xml with key value pair in t-sql

In the below code block I'm able to query till DataElements. for below xml DECLARE @xmlString XML; SELECT @xmlString=' 570
0
votes
1 answer

DB2 how do I replace a double quote returned by an XML element

I am able to successfully retrieve the value of XML element using the following SQL *SELECT XMLQUERY('$item/*:ItemSpec/*:AdditionalDescription/*:ABCDescription/text()' PASSING productval.value_xml as "item") AS H_DESCRIPTION FROM USER1.XMETA* This…
Mohan
  • 3
  • 1
0
votes
2 answers

Referencing the Current Context in a T-SQL nodes() XQuery

Is it possible to effect a join between two T-SQL nodes() calls by filtering the second nodes() based on the context node of the first? In the example below, I'm trying to return a table showing PersonID, Name and Position. My attempt at referencing…
Ben Gribaudo
  • 5,057
  • 1
  • 40
  • 75
0
votes
1 answer

How to get specified attributes from an xml column in Sqlserver

I have a xml column called MesssageContent in my db as:
Darren
  • 15
  • 5
0
votes
2 answers

Why simple subtraction of two sets is not working?

I have following xml file. I need to find members are in $c which are not in $v: (C) - (V) = desired result let $c := /transport/trips/trip let $v := /transport/trips/trip where (data($c/@vehicle)="PKR856") return
Bernard
  • 4,240
  • 18
  • 55
  • 88
0
votes
1 answer

XQuery / SQL Server iterative replace statement

My question is how to put an iterative loop into a SQL Server 8 SQL procedure that uses XQuery to find and change node values. I have a SQL Server Database table with a field called Data containing XML data, something like the…
fbc
  • 137
  • 2
  • 6
0
votes
1 answer

How can I update a specific node in a xml column

I have the following data stored in my table [fixed_width_export_specification_t][specification_xml]' sys_header
0
votes
2 answers

Extract proper data from a sql server XML column using XQuery

I am having an issue trying to get proper data from an XML type column: "<"ArrayOfAccountInformation xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.Balance.com/"> …
SafwanMZ
  • 17
  • 3
0
votes
1 answer

XQuery by attribute in value function

I'm attempting to filter out books with 'Romance' under Subject without using a WHERE filter. 402 Adult Book Romance $35.99
Le_RedditUser
  • 113
  • 1
  • 4
  • 10
0
votes
2 answers

Inequality in XQuery

I am trying to list the IDs of students who have all A's. Here is my XQuery: for $s1 in doc("Unv.xml")//Enrollment[Grade = 'A']/StudentInfo/@oID let $s2 := doc("Unv.xml")//Enrollment[Grade != 'A']/StudentInfo/@oID where every $id in $s1 satisfies…
0
votes
1 answer

complex XML XQUERY invalid content after root element's end tag [err:FODC0002]

1.Alexa API response about google.com: http://pastebin.com/C5yjSjCf -in other words it is representing one row from 12 simple tables called "ContactInfo" "Rank by Country", ... and just one more example (facebook.com) http://pastebin.com/mP813jYS…
iloveregex
  • 57
  • 2
  • 12
0
votes
1 answer

Query To Read Data From XML

There's already a few similar questions on here, but they don't seem to work for me. I need to query an XML file to extract data from it, so we can use the result of the query for other purposes. I have searched on the net for a method to do this,…
Michiel281
  • 55
  • 1
  • 4
0
votes
1 answer

DB2 pureXML index usage in ORDER BY clause

I got a problem with the index usage in DB2 XML. I have a database table with users, consisting of id + xml document + timestamp. The thing i'm interested in is to find users and order them by join date. The index definition: create index…
Martin Müller
  • 2,565
  • 21
  • 32
0
votes
1 answer

How to check the multiple values against a same name attribute in xml column of DB2 using XMLQuery?

Here is my query which I'm using to fetch the data from my table. SELECT XMLQUERY('$INFO/root/database_systems/system/@name = ("SYS1","SYS2","SYS3")') FROM MyTable WHERE ACCT_ID = 'ID-1234'; Ok actually it is returning me true. Just because of the…
Superman
  • 871
  • 2
  • 13
  • 31
0
votes
1 answer

SqlServer XQuery always concat two fields

I want to get somedata from one column only from an xml field:
MirlvsMaximvs
  • 1,453
  • 1
  • 24
  • 34